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

Does anyone know why my script that gives EXP on kill to all players wont work?

Asked by 4 years ago
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)

0
does it print no EXP given or nothing? shackfu 14 — 4y
0
nope Trisodin529 89 — 4y
0
if it doesn't print no EXP given then I can't see how it could not be doing the if statement since it's in a while loop. Try putting a print in the if statement? shackfu 14 — 4y
0
is ZP1 a part maumaumaumaumaumua 628 — 4y
View all comments (2 more)
0
Yes. Trisodin529 89 — 4y
0
Wait, the script wont run Trisodin529 89 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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)
0
glad u got it working girl :D royaltoe 5144 — 4y
Ad

Answer this question