Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

0

ignore the stuff in brackets i had to do it or i couldnt ask question

1

you combined the equipped and unequipped functions, seperate the two.

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.