Help With setting player for a variable

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

Epic

Member
Nov 10, 2022
1
0
1
23
Hello, I am currently having trouble setting a player in a variable to apply an affect to them. I was looking around the forums and didn't see anything that really helped. This might be a quick fix seeing as I only started working with skript a week or so ago, but I wanted to check just in case.

The idea: I am trying to make it so that when a skeleton shoots you , a random number is drawn. If the number is 1, the player is not effected, but if the number is 2, the player has wither 3 applied to them for 8 seconds. I have all of the stuff working except a way to make it so only players are affected by the arrows, and not any mobs in an area. I'm not sure how to identify what player was hit and set their name in a variable so they receive the wither effect. Any help with this would be much appreciated!

Heres my code:
on damage:
projectile exists
projectile is a arrow:
set {_player-hit} to %player%
if {_necroAttack} is 1:
set {_empty} to 1
if {_necroAttack} is 2:
apply potion of wither of tier 3 to {_player-hit}
set {_necroAttack} to random integer between 1 and 2
on skript load:
set {empty} to 0
 
Code:
on damage of player: # When using a damage event on a player, specify 'of player'
    projectile exists:
        projectile is a arrow:
            set {_player-hit} to victim # % symbols are only needed in texts
            set {_random} to a random integer between 1 and 2 # Set it to integer so {_random} doesn't output 1.266327 or something 
            if {_random} = 1:
                stop
            else if {_random} = 2:
                apply wither 3 to {_player-hit} for 8 seconds

on skript load: # Not quite sure what these are supposed to do, but I'm not sure you'll need them
    set {empty} to 0

This should work, if you need any help with this script or something doesn't work (it should since I tested it on a server without addons), just reply or message me. Have a good day!
 
  • Like
Reactions: Epic
Status
Not open for further replies.