Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to delete a player's value after they die?

Asked by
Uzuntu 6
7 years ago

I'm working on a script that delete's a player's value when they die, so that they are not in the round anymore.

I have the value stored in ServerStorage inside of a folder named 'PlayersAlive'.

The game detects when a player dies, but I'm not quite sure how to just delete their value instead of the entire list of values.

This is what I have:

elseif Player.Character.Humanoid.Health == 0 then

        print "Player died!"

        break


        end

Not quite sure what to add in here? Thanks for any help, and feel free to ask for more info if you need it.

0
game.ServerStorage.PlayersFolder[Player.Name]:Destroy() --This is assuming the values name is equal to the player's name. Thetacah 712 — 7y
0
Thank you, I got it to work. Uzuntu 6 — 7y

1 answer

Log in to vote
1
Answered by
xPolarium 1388 Moderation Voter
7 years ago
Edited 7 years ago

If you can provide more code than that then it would be great.

First of all, break is a command used to "break" a loop. In this case, I'm not sure if you are inside a loop but if you are not then try using return to get out of the if statement instead.

A method for detecting when a Player dies is using the Died() event through the player's Humanoid.

character.Humanoid.Died:connect(function()
    print("Player "..character.Name.." has died!")


    --You would also remove the value in here

    local value = --[[Location of the value]]--

    value:Destroy()
    --or
    value.Value = false -- if its a bool value.
end)

You should provide a little bit more code so I can actually see what you're trying to do.

Ad

Answer this question