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

When I Kill a Humanoid, How to change the value on a number value in replicated storage?

So when I do an "if" statement, which dose not work, it wont give me + 5 in value towards the NumberValue found in Replicated storage Example:

local Cash = game.ReplicatedStorage:WaitForChild("NumberValue")
local HP = script.Parent.Health

end)

now NumberValue is my Value I call "cash", and I need when the Humanoid his <= 0 then will give + 5 value once.

I dont want an if statement but more of a way to figure this out

Conclusion NumberValue is added 5 every time the humanoid dies (hits 0 Health)

Thanks For your awnsers!

1 answer

✓ Accepted answer

You could use a function to detect when a player has died

local Cash = game.ReplicatedStorage:WaitForChild("NumberValue")

game:GetService('Players').PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character:WaitForChild("Humanoid").Died:connect(function()
			Cash.Value = Cash.Value + 5
		end)
	end)
end)

Accept answer if helped and tell me if anything is wrong!

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