Item gets given to all players

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

TimeByte

Member
Jul 16, 2022
1
0
1
24
I can't figure out why it gives it to all players

Script Version: 2.6.3
Script Author: Me
Full Code:

every 15 seconds in world "world":
loop all players:
if {randomItems} is not set:
give random item out of all items to loop-player
command /toggleitems:
trigger:
if {randomItems} is not set:
message "&7Random items have been &cdisabled"
set {randomItems} to false
else:
message "&7Random items have been &aenabled"
delete {randomItems}

Errors on Reload: None
 
try this(every "-" is one tab):
every 15 seconds in world "world":
-set {_number} to number of online players
-set {_number2} to random integer between 1 and {_number}
-loop all players:
--add 1 to {_loopnumber}
--if {_loopnumber} = {_number2}:
---give random item out of all items to loop-player
---clear {_loopnumber}
---stop loop

command /toggleitems:
- trigger:
--if {randomItems} is not set:
---message "&7Random items have been &cdisabled"
---set {randomItems} to false
--else:
---message "&7Random items have been &aenabled"
---delete {randomItems}
 
Hey there, if you want to check {randomItems} for every players, you need to make it as a player variable.
Which means {randomItems.%player's uuid%} (uuid so it recognize it even if they change name)

I let you guess the rest of the changes that goes with it


EDIT: In the loop don't forget to use {randomItems.%loop-player's uuid%} instead of {randomItems.%player's uuid%}
 
Status
Not open for further replies.