I made a decent gun with animations but the only problem is the equipped animation. I'm trying to stop playing it when the player unequips the weapon. Here's the main parts of the script that I'm having problems with.
local plr = game:GetService("Players").LocalPlayer
local character = plr.CharacterAdded:wait()
gun.Equipped:connect(function(gunstarts)
equip = true
gun:WaitForChild("GunGUI"):Clone().Parent = plr.PlayerGui
plr.PlayerGui:FindFirstChild("GunGUI"):FindFirstChild("Frame"):FindFirstChild("Title").Text = gun.Name
while true do
plr.PlayerGui:FindFirstChild("GunGUI"):FindFirstChild("Frame"):FindFirstChild("MainText").Text = ammo.."/"..maxammo
wait()
if shooting == false and equip == true and isreloading == false then
repeat
character:FindFirstChild("Humanoid"):LoadAnimation(handle:WaitForChild("HoldAnim")):Play()
wait(.001)
until shooting == true or equip == false or isreloading == true
end
end
end)
gun.Unequipped:connect(function(gunstops)
equip = false
plr.PlayerGui:FindFirstChild("GunGUI"):remove()
end)
Everything else works, nothing in the output. The animation just won't stop playing. Help?
