Troubles with Variables & Blocks

  • 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 community!

    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.

NeonEthan

Member
Jul 6, 2020
2
0
1
I've started Skript today, and have been working on a skript which gives you a block that you must shift on in order to continue (in a little game I am making).

I'm not sure how to add the code in a special format (and if someone could help me with that, so I can edit this post, thatd be great!) but here is what I have so far.

on load:
delete {blocks::*}
add "grass block" to {blocks::*}
add "sand block" to {blocks::*}

command /blockshuffle:
trigger:
set {block} to a random object out of {blocks::*}
send "&cYour new randomized block is &a%{block}%!"

on sneak toggle:
if player is not sneaking:
loop all players:
if block under player is {block}:
broadcast "Test"

It's far from finished, but the problem I'm having is that when it checks for if block under player is {block}:, the block that is defined (either sand block or grass block) does not work when I shift on it.

It gives me "&cYour new randomized block is &asand block!" for example
I go to try and shift on the sand block, and it does not work.

If I replace if block under player is {block}: with "sand block" or "grass block" it works (aka if block under player is sand block) but not if I am defining the variable, randomizing it, and then using that variable to shift on.

I'm not sure what I'm doing wrong, and again, I'm not too confident on Skript since I have just started today.
Thank you.
 
try this
Code:
on load:
    delete {blocks::*}
    add "grass block" to {blocks::*}
    add "sand block" to {blocks::*}

command /blockshuffle:
    trigger:
        set {block} to a random object out of {blocks::*}
        send "&cYour new randomized block is &a%{block}%!"

on sneak toggle:
    set {_block} to block under player
    if {_block} = {block}:
        broadcast "Test"

To send code, do the following
upload_2020-7-7_23-0-53.png

[doublepost=1594155700,1594155653][/doublepost]Also, I removed some lines from your code, because they simpley made no sense
 
Status
Not open for further replies.