I want to make a player do an animation loop when a button is pressed, and cancel when the button is pressed again.
The issue is that the script cannot tell if an animation is playing.
The script is a normal script and I have tried using .IsPlaying and :IsPlaying() both in Booleans that are in a while true do loop but I cant get it to work so I had started my script back.
Script:
local Button = script.Parent
local Emote = Button["Spin Emote"] -- Insert Emote
local EmoteOn = false
local StarterPack = game:GetService("StarterPack")
local fists = game.StarterPack.Fists
local rs = game:GetService("ReplicatedStorage")
local spin = rs:FindFirstChild("HumanoidToEmotes")
spin.OnServerEvent:Connect(function(player, Humanoid)
Button.MouseButton1Down:Connect(function()
local LoadEmote = Humanoid:LoadAnimation(Emote)
if EmoteOn == false then
LoadEmote:Play()
end
end)
end)
Does anyone know how i can do this?