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

Killing the zombie doesn't change the value?

Asked by 3 years ago
Edited 3 years ago

When the zombie dies it doesn't change the value

local zombiesleft = workspace.RoundSYSTEM.ZombiesLeft.Value
while true do
    wait(0.001)
    script.Parent:WaitForChild("Humanoid").Died:Connect(function()
        print('Zombie Died')
        zombiesleft -= 1
        script:Destroy()
    end)
end
0
does it print "Zombie Died" surviarlTheJefkillre 55 — 3y
0
yes it does basloxrob 9 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

The error is on line 1 : I think you want to have access to change the value property of "ZombiesLeft". What you're actually doing is that you're setting the value to the number of zombies left. By doing this you will get the number of ZombiesLeft. However, you will not be able to change it. The correct way of doing this is :

local zombiesleft = workspace.RoundSYSTEM.ZombiesLeft
while true do
    wait(0.001)
    script.Parent:WaitForChild("Humanoid").Died:Connect(function()
        print('Zombie Died')
        zombiesleft.Value -= 1 --not sure of the syntax over here you can also use   
        --zombiesleft.Value = zombiesleft.Value - 1
        script:Destroy()
    end)
end

Now it might work ! Hope this helped :)

Ad

Answer this question