My stun while loop wont break once the object is deleted. I think it has something to do with the wait, but when I tried to remove the wait it crashed my studio.
local Character = script.Parent
local Debris = game:GetService("Debris")
local debounce = false
Character.ChildAdded:Connect(function(child)
if child.Name == "BarrageStun" then
while child ~= nil do
if child == nil then
break
else
wait(.000001)
if not Character:FindFirstChild("Humanoid").WalkSpeed == 0 then
Character:FindFirstChild("Humanoid").WalkSpeed = 0
end
end
end
end
end)
Character.ChildRemoved:Connect(function(OldChild)
if OldChild.Name == "BarrageStun" then
Character:FindFirstChild("Humanoid").WalkSpeed = 16
end
end)