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

Trouble Changing an IntValue When Zombie is killed?

Asked by
TriteA1 30
4 years ago

So I'm trying to make a script that changes an IntValue by 1 every time one of the 7 zombies is killed. However when a zombie is killed it keeps outputting the same number '1', it isn't adding up the deaths. If anyone could please help me with this that would be very appreciated, thanks.

-This script is placed inside the humanoid of the zombie.

Wave = game.ReplicatedStorage.Wave.Value

while  true do
    wait(1)

if script.Parent.Health == 0 then
    Wave = Wave + 1
    print(Wave)
    return 
end
end

1 answer

Log in to vote
0
Answered by 4 years ago

Can't test it right now, but removing the .Value at the end of your first line of code should be enough; this way its the path to your Wave object what gets stored in your 'Wave' variable instead of its value, thus allowing it to get updated correctly.

Wave = game.ReplicatedStorage.Wave -- Removed ".Value"

while true do
    wait(1)

    if script.Parent.Health == 0 then
        Wave.Value = Wave.Value + 1
        print(Wave.Value)
        return 
    end
end
Ad

Answer this question