Skript right-click-on-block-detection

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

RazorBl8de

Member
Nov 11, 2022
1
0
1
16
Script Version: 2.6.3
Script Author: Me (RazorBl8de)
Minecraft Version: 1.18.2

Hi I have been trying to make a right-click detection for making a closet that you can hide in.
I know that this code doesn't work, but it tells you want I want done.
Basically, if a player right clicks an acacia door, they get teleported to the nearest invisable armorstand with the tag 'closet' , the player gets invisability, and a tag is applied so that the player can leave the closet when the player shifts.

on right click:
if clicked block is "<acacia_door>":
execute console command "/teleport <player> @e[sort=nearest,tag=closet]"
execute console command "/effect give <player> invisibility 1000000 1 true"
execute console command "/tag <player> add inCloset"

if player tag is inCloset:
if player crouches:
execute console command "/teleport <player> @e[sort=nearest,tag=closet] ^ ^ ^1"
execute console command "/effect clear <player> invisibility"
execute console command "/tag <player> remove inCloset"

I am new to Skript and I don't know much. could you please fix this code and tell me how you fixed it please.
Thank you.
[doublepost=1668581908,1668581819][/doublepost]And yes, it is indented correctly.
Here is the code in it's correct format: https://pastebin.com/s0hFCntN
 
I recommend putting some of the stuff in a datapack.

Skript:
Code:
on right click on acacia door:
    execute command "execute as %player% run function bla:1"

Datapack File 1.mcfunction in datapack:
Code:
teleport @s @e[sort=nearest,tag=closet]
effect give @s invisibility 1000000 1 true
tag @s add inCloset

Skript:
Code:
if player is sneaking:
        execute command "execute as %player% run function bla:2"

Datapack - File 2.mcfunction in datapack:
Code:
execute as @p[tag=inCloset] run teleport @s @e[sort=nearest,tag=closet] ^ ^ ^1
execute as @p[tag=inCloset] run effect clear @s invisibility
execute as @p[tag=inCloset] run tag @s remove inCloset

I think this is the best solution for you
 
Status
Not open for further replies.