"Zombie" is the zombies in the game which is in workspace. "RealMoney" is made when game starts so is in the player and isn't in leaderstats . "CoinBoost" is made by pets it's a variable saved of how much extra coins pets give you. This Script is for when the Zombie dies and money is given plus the value the coin boost has.
local Zombie = game.Workspace.Zombie local char = script.Parent.Parent local plr = game.Players:GetPlayerFromCharacter(char) local RealMoney = plr:FindFirstChild("RealMoney") local boost = plr:FindFirstChild("CoinBoost") Zombie:WaitForChild("Zombie").Died:Connect(function() plr.RealMoney.Value = plr.RealMoney.Value + 100 + boost.Value end)
The died event is only for the instance humanoid. This would work:
local Zombie = game.Workspace.Zombie local char = script.Parent.Parent local plr = game.Players:GetPlayerFromCharacter(char) local RealMoney = plr:FindFirstChild("RealMoney") local boost = plr:FindFirstChild("CoinBoost") Zombie:WaitForChild("Zombie"):WaitForChild("Humanoid").Died:Connect(function() plr.RealMoney.Value = plr.RealMoney.Value + 100 + boost.Value end)
The .Died
event is for Humanoid
s, Please do more research before asking next time.