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

How can I give everyone cash if this zombie dies?

Asked by 3 years ago
Edited 3 years ago

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

0
make it so when the zombie dies , it loops through all the players in the game and gives them cash Tizzel40 243 — 3y

1 answer

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
3 years ago
Edited 3 years ago
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)
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 jmarsh33 7 — 3y
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 jmarsh33 7 — 3y
0
Updated the code, if it works please mark it as answered Pupppy44 671 — 3y
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 Pupppy44 671 — 3y
Ad

Answer this question