How to make a trap block

  • 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.

zeibo

Member
May 16, 2017
11
0
0
27
I wanna make the cracked stone bricks disappear for a while when someone moves onto them.

But I can't make it happen correctly.

Sometimes the blocks won't spawn at their original position......


code_language.skript:
on walking on Cracked Stone Bricks:
        send "watch out!" to player
        set {lx.crackedbricks.%player%} to the player's x-coordinate
        set {ly.crackedbricks.%player%} to the player's y-coordinate
        set {lz.crackedbricks.%player%} to the player's z-coordinate
        set {lw.crackedbricks.%player%} to the player's world
        wait 3 tick
        subtract 1 from {ly.crackedbricks.%player%}
        set block at location at {lx.crackedbricks.%player%}, {ly.crackedbricks.%player%}, {lz.crackedbricks.%player%} in world {lw.crackedbricks.%player%} to air
        wait 10 tick
        set block at location at {lx.crackedbricks.%player%}, {ly.crackedbricks.%player%}, {lz.crackedbricks.%player%} in world {lw.crackedbricks.%player%} to Cracked Stone Bricks
 
Okay, so I was trying something similar a lonnnggg time ago, where it would make tnt turn into primed tnt if a player stepped on it.

This may be what you're looking for:

code_language.skript:
on walking on Cracked Stone Bricks:
    send "Watch Out!" to player
    set event-block to air
    wait 10 ticks
    set event-block to Cracked Stone Bricks

Now, there is a problem with this: if a player is sneaking along the edge of the block, they're technically not walking on it, and thus this event does not get called.
 
It's just that the event won't be called if the player is able to "hang on" to the edge of the block, since the player technically isn't above the block yet.

A solution, although may cause lag, would be to use the "on any movement" event.
 
Status
Not open for further replies.