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

How can I give everyone cash if this zombie dies?

I am making a script that gives everybody "cash" (leaderstats name) if this zombie npc dies. My current code doesn't work. If you'd like a look, here it is. Thank you in advance.

local Humanoid local Leaderstats = workspace:FindfirstChild("leaderstats")

if Humanoid.Health <2 then Leaderstats.Cash.Value = Leaderstats.Cash.Value +2 end

1 comment

0

make it so when the zombie dies , it loops through all the players in the game and gives them cash

1 answer

local Humanoid = (the humanoid)
function Died()
for i,Player in pairs(game.Players:GetChildren()) do
Player.leaderstats.currencyname.Value = Player.leaderstats.currencyname.Value + 2
end
end

Humanoid.Died:Connect(Died)

4 comments

0

I appreciate the answer, but for some reason, the humanoid part has an orange underline despite the Humanoid's name being correct. I think that must be why it isn't working

0

this is the script:local Humanoid = (Zombie) if Humanoid.Died then for i,Player in pairs(game.Players:GetChildren()) do Player.leaderstats.Cash.Value = Player.leaderstats.Cash.Value + 2 end end

0

Updated the code, if it works please mark it as answered

0

By the way, "local Humanoid = (Zombie)" would result in an error. If the character is in the workspace for example, you could do workspace:FindFirstChild("Zombie").Humanoid

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