Simple issue with checking if a tool equipped

Sorry for the very stupid question it is getting late and my brain is not working properly
I am super stumped on why my loops are not working when equipped is set to false or true
When If first load in, the lua while not equipped prints as required but the second I equip, while equipped do does not work and after i unequip while not equipped doesn’t work either.

local tool = script.Parent
local equipped = false
local player = game.Players.LocalPlayer
local test = true

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

while equipped do
	print("yes")
	wait(1)
end

while not equipped do
	print("Not")
	wait(1)
end```

Thats because it ends as soon as the script loads due to equipped already being false, if you want it to print you should put it after you set equipped to true inside the function.

local tool = script.Parent
local equipped = false
local player = game.Players.LocalPlayer
local test = true

tool.Equipped:Connect(function()
	equipped = true
    while equipped do
	   print("yes")
	   wait(1)
    end
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

while not equipped do
	print("Not")
	wait(1)
end
3 Likes