Need help with periodical and looping (im stressed)

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

RedDiamond

Member
Nov 30, 2020
21
0
1
23
Ok so i want to make a gen (kinda) skript, so basically when the player right click a music disc it will active or we can say the variable turn to true, and when its activate it will give player an iron block every 4 seconds, but the problem is im using "loop all players" and that make the every 4 seconds give player item effect work when all of the player on the server turn their variable to true (or we can say if all player turn on their gens) and i dont want that, i want when a single player turn on their gen the gen will work and only give it to the player, sorry for my bad english and explaination, if u need more info u can ask

Code:
on right click:
  if player is holding a music disc strad named "&fIron &7Generator" with lore "{@ironl}" and "&7Status: &cOff":
    if {gensiron.%player%} is false:
      set {gensiron.%player%} to true
      set line 2 of lore of player's tool to "&7Status: &aOn"
      send "{@p} {@on}"
      if {gensiron.%player%} is true:
        if player is online:
          while player has music disc stard:
            give player 1 iron block
            wait 4 seconds
        else if player is not online:
          stop
    else if {gensiron.%player%} is true:
      send "{@p} {@only1}"
  else if player is holding a music disc strad named "&fIron &7Generator" with lore "{@ironl}" and "&7Status: &aOn":
    send "{@p} {@alreadyon}"
on left click:
  if player is holding a music disc strad named "&fIron &7Generator" with lore "{@ironl}" and "&7Status: &aOn":
    set {gensiron.%player%} to false
    set line 2 of lore of player's tool to "&7Status: &cOff"
    send "{@p} {@off}"
  else if player is holding a music disc strad named "&fIron &7Generator" with lore "{@ironl}" and "&7Status: &cOff":
    send "{@p} {@alreadyoff}"
    set {gensiron.%player%} to false
every 4 seconds:
  loop all players:
    if {gensiron.%loop-player%} is true:
      if loop-player is online:
        if loop-player has music disc strad:
          give loop-player 1 iron Block
      else if loop-player is not online:
        stop
    else if {gensiron.%loop-player%} is false:
      stop
on drop of music disc strad:
  cancel event
  send "{@p} {@drop} to player"

i hope someone can help me with this, its so confusing for me, thank you :emoji_slight_smile:
 
Status
Not open for further replies.