local EXP = script.Parent.Parent.EXP local Gold = script.Parent.Parent.Gold local ZP1 = game.Workspace.ZP1 while true do wait(0.1) if ZP1.CanCollide == true then EXP.Value = EXP.Value + 1 Gold.Value = Gold.Value + 1 wait(0.2) game.Workspace.ZP1.CanCollide = false else print("No EXP given.") end end
In the game, when the zombie is killed, it turns on CanCollide, which is supposed to trigger this script. However, it doesn't add the EXP or gold, even when CanCollide is on. Can someone help me with this? (btw it gives the exp to everyone)
I was able to fix this, by making a script inside the Zombie. Here it is.
local zombie = script.Parent local Humanoid = zombie:WaitForChild("Zombie") Humanoid.Died:Connect(function() for i,Player in pairs(game.Players:GetPlayers()) do Player.leaderstats.EXP.Value = Player.leaderstats.EXP.Value + 1 Player.leaderstats.Gold.Value = Player.leaderstats.Gold.Value + 1 print("Exp awarded") end wait(2) zombie:Destroy() end)