Need help with offhand potion effects

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

Duck

Member
Mar 20, 2022
1
0
1
15
Hi, so I made a script for holding a specific item in your offhand and it gives potion effects. This works in with 1 or 2 people, but when tried on a whole server, there was a ton of lag. Any help?

Code:
on inventory close:
    while player is online:
        loop all players:
            if player's offhand tool is flint named "&6Test":
                remove strength from player
                apply strength 1 to player for 5 seconds
        wait 5 seconds
Please help
 
i'd use something like this maybe?

Code:
every 5 seconds in "world":
  loop all players:     
    if player's offhand tool is flint named "&6Test":
      apply strength 1 to player for 5 seconds

also you might want to consider an offhand attack damage attribute instead for strength so you don't have to deal with potion effects. but that's just my opinion
 
Hi, so I made a script for holding a specific item in your offhand and it gives potion effects. This works in with 1 or 2 people, but when tried on a whole server, there was a ton of lag. Any help?

Code:
on inventory close:
    while player is online:
        loop all players:
            if player's offhand tool is flint named "&6Test":
                remove strength from player
                apply strength 1 to player for 5 seconds
        wait 5 seconds
Please help
try this
Code:
on swap hand item:
    if player's offhand tool is flint named "&6Test":
        remove strength from player
        apply strength 1 to player for 5 seconds
        wait 5 seconds
    else if player's offhand tool is flint named "&6Test": #other item
        #code
    else: #when player item is not a special item
        #code, example remove potions effects or nothing since the effect last 5 seconds you just can remove this else
[doublepost=1649810038,1649809975][/doublepost]
i'd use something like this maybe?

Code:
every 5 seconds in "world":
  loop all players:   
    if player's offhand tool is flint named "&6Test":
      apply strength 1 to player for 5 seconds

also you might want to consider an offhand attack damage attribute instead for strength so you don't have to deal with potion effects. but that's just my opinion
this is a good one because the other code is creating a while loop for everyone every time someone opens the inventory
 
Last edited:
Status
Not open for further replies.