Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

my idle animation will play but i cant get it to stop, how do i fix this?

I have searched for a while and tried a couple solutions like creating a separate function.

the way my code works is the local script fires the server with a string, and then the server uses that string to decide which animation its gonna play (slash, idle, etc) here is my code

Server:

local rem = script.Parent:WaitForChild("RemoteEvent")

rem.OnServerEvent:Connect(function(player, stringe)	
	if stringe == "Idle" then
		local hum = player.Character.Humanoid
		local animator = hum.Animator
		local animation = game.ServerStorage.Animations.IdlePin
		
		local animationPlay = animator:LoadAnimation(animation)
		animationPlay:Play()
	elseif stringe == "IdleUnequip" then
		local hum = player.Character.Humanoid
		local animator = hum.Animator
		local animation = game.ServerStorage.Animations.IdlePin
		
		local track = animator:LoadAnimation(animation)
			track:Stop()
	end
end)

Local:

local equipped = false
local stringe
local rem = script.Parent:WaitForChild("RemoteEvent")

script.Parent.Equipped:Connect(function()
	stringe = "Idle"
	
	rem:FireServer(stringe)
	equipped = true
end)

script.Parent.Unequipped:Connect(function()
	stringe = "IdleUnequip"

	rem:FireServer(stringe)
	equipped = false
end)

1 answer

I found the answer

for anyone who wants to know the load animation had to be globalized

This discussion is preserved as it was. New answers, comments, and votes are closed.