Animations not looping and server/client bugged

I’m trying to make an emote menu, most of It worked, but I recently converted the script into a local script and normal script controlled by remote emotes and now for some reason when its on the actual player’s screen it only does the animation 1 time, but when I switch to the current client option, it is looping and doesn’t stop looping. Every time I re-click the button, the animation gets faster but nobody can see the animations in the actual games.

My LocalScript:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local frame = script.Parent.ScrollingFrame

local playing = false
local event = game.ReplicatedStorage.EmotesController
local debounce = false

game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)

for i, v in pairs(frame:GetChildren()) do
	if v:IsA("ImageButton") then
		v.MouseButton1Click:Connect(function()
			if playing == false and debounce == false then
				debounce = true
				event:FireServer(v.Animation, "Play")
				playing = true
				wait(3)
				debounce = false
			elseif playing == true and debounce == false then
				debounce = true
				event:FireServer(v.Animation, "Stop")
				playing = false
				wait(3)
				debounce = false
			end
		end)
	end
end

My serverscript:

event.OnServerEvent:Connect(function(player, anim, action)
	if action == "Play" then
		local char = player.Character
		local hum = char.Humanoid
		local emote = hum:LoadAnimation(anim)
		hum.WalkSpeed = 0
		hum.JumpPower = 0
		emote.Looped = true
		emote.Priority = Enum.AnimationPriority.Action
		emote:Play()
	elseif action == "Stop" then
		local char = player.Character
		local hum = char.Humanoid
		local emote = hum:LoadAnimation(anim)
		hum.WalkSpeed = 16
		hum.JumpPower = 50
		emote.Looped = false
		emote:Stop()
	end
end)

Hii, the issue might be related to how the animations are being triggered and handled. Make sure that the v.Animation value passed to event:FireServer(v.Animation, “Play”) is correctly referencing the animation in ReplicatedStorage. Another issue I see is that in your ServerScript when stopping the animation you are creating a new animation with hum:LoadAnimation(anim) instead of using the existing emote that was created when playing the animation. This can lead to unwanted behavior. Instead, you should store the emote when playing the animation and use it to stop the animation. I hope my feedback helps!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.