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

can somebody please fix this error? (very tool sscript color3)

Asked by 5 years ago

local Equipped = false

script.parent.Equipped:Connect(function()

Equipped = true

repeat
    wait(1)

    script.Parent.Power.Value = script.Parent.Power.Value - 1

until Equipped == false

script.Parent.Unequipped:Connect(function()

    Equipped = false

end)

end)

when i unequip the tool it keeps subtracting power

0
ignore the stuff in brackets i had to do it or i couldnt ask question DimondWolfLord -19 — 5y
1
you combined the equipped and unequipped functions, seperate the two. DinozCreates 1070 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

You had combined the two functions. I've also cleaned up the formatting and used a while loop to make it much neater.

local Equipped = false

script.parent.Equipped:Connect(function()
    Equipped = true
    while Equipped do
        script.Parent.Power.Value = script.Parent.Power.Value - 1
        wait(1)
    end
end)

script.Parent.Unequipped:Connect(function()
    Equipped = false
end)
Ad

Answer this question