Animation not stopping after firing an event

Hey guys! I have a problem where an animation keeps playing when an event if fired in the middle of it. Heres the code

if cooldown == false and isdropping == false then
			cooldown = true
			throwRepEvent:FireServer()
			animation.AnimationId = "rbxassetid://8643642845"
			local playanim = hum:LoadAnimation(animation)
			playanim:Play()
			wait(1)
			playanim:Stop()
			wait(0.3)
			cooldown = false
		end

As you can see, I added a remote event called 'throwRepEvent:FireServer()". When I have this line of code in the program, the whole animation keeps repeating but as soon as I delete that one line of code, the whole animation works perfectly. Anyone have any idea why this is happening?

– The Code with the Event vvv

–The Code without the Event vvv

Can you share the portion of the server script where this β€œ:FireServer()” call is being listened for with a corresponding .OnServerEvent event?

With that information finding the root cause of the issue will be a lot easier.

		
		
		events.ThrowItem.OnServerEvent:Connect(function()
			wait(0.37)
			RC:Destroy()
			local BV = Instance.new("BodyVelocity")
			BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			BV.Velocity = plr.Character.HumanoidRootPart.CFrame.LookVector * 17
			BV.Parent = script.Parent.Parent
			AddGui:Destroy()
			game.Debris:AddItem(BV,0.57)
			script.Parent.Enabled = true
			isholdval.Value = false
			wait(0.777)
			script.Parent.Parent.Parent = workspace
		end)
		
		

AHHH I SEE WHAT I DID WRONG. I destroyed the gui too early so the script just kept repeating THANK YOU!!!