Help with animation

What I want
Basically each time I equip a tool an animation plays and whenver I unequip it it stops, kind of like an idle
What’s the issue?
The animation never stops

local script

local plr = game.Players.LocalPlayer
local replicatedStorage = game:GetService(“ReplicatedStorage”)
local transparent = replicatedStorage.Books.Transparent
script.Parent.Equipped:Connect(function()
transparent:FireServer(“visible”)
end)
script.Parent.Unequipped:Connect(function()
transparent:FireServer(“transparent”)
end)

server script

transparent.OnServerEvent:Connect(function(player,stringvalue)
local FXFolderMagic = game.ServerScriptService:WaitForChild(“FXFolderMagic”)
local Anims = FXFolderMagic.Anims
local char = player.Character
local hum = char:WaitForChild(“Humanoid”)
local humrp = char:WaitForChild(“HumanoidRootPart”)
local Animation = hum:LoadAnimation(Anims.BookHold)

if stringvalue == "visible" then	
	Animation:Play()
	for i,v in pairs(book2:GetDescendants()) do
			if (v:IsA("BasePart")) then
			v.Transparency = 0
		end
	end
	for i,v in pairs(book:GetDescendants()) do
		if (v:IsA("BasePart")) then
			v.Transparency = 1
		end
	end
end

if stringvalue == "transparent" then
	Animation:Stop()
	for i,v in pairs(book2:GetDescendants()) do
		if (v:IsA("BasePart")) then
			v.Transparency = 1		
		end
	end
	for i,v in pairs(book:GetDescendants()) do
			if (v:IsA("BasePart")) then
			v.Transparency = 0
		end
	end
end

end)

It’s likely your animation never ends because everytime you call the remote, it loads the same idle animation into your Humanoid, so it only stops that loaded animation on that time the event was fired, ignoring the other loaded idle animations

Can’t you make the animation play and stop from the localscript? The animation will replicate to other clients if it’s being loaded onto a character

1 Like

Thank you, I fixed it, I’m kinda new to scripting and I didnt knew that they replicate.

1 Like