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

What is wrong with the script, It's to do with Died:Connect(function()?

Asked by 4 years ago

"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)

1
.Humanoid.Died greatneil80 2647 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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)
Ad
Log in to vote
-1
Answered by 4 years ago

The .Died event is for Humanoids, Please do more research before asking next time.

0
he could have renamed the Humanoid to "Zombie" Mayk728 855 — 4y
0
Yh I did I said it FluffySheep46209 369 — 4y

Answer this question