Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

2 comments

0

game.ServerStorage.PlayersFolder[Player.Name]:Destroy() --This is assuming the values name is equal to the player's name.

0

Thank you, I got it to work.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.