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

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

Asked by 6 years ago

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

Log in to vote
0
Answered by
Prestory 1395 Moderation Voter
6 years ago

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!

Ad

Answer this question