Basically, i have emote buttons. It works, the music works. The emote ends when you move, but it doesn't work twice. If you click, emotes dont work again.
Heres the script:
local emote = false
local name = ''
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=nil"
local animTrack = nil
local canPlay = true
local audio = false
for i,v in pairs(script.Parent.EmotesTab:GetChildren()) do
if v:IsA("ImageButton") then
v.MouseButton1Down:connect(function()
animation.AnimationId = ("http://www.roblox.com/Asset?ID="..v.Name)
if canPlay then
local player = game.Players.LocalPlayer.Character
canPlay = false
animTrack = player.Humanoid:LoadAnimation(animation)
animTrack.KeyframeReached:connect(function(keyframeName)
if keyframeName == "ElectrocuteEnd" then
canPlay = true
end
end)
animTrack:Play()
local pos = game.Players.LocalPlayer.Character.UpperTorso.Position
if v:FindFirstChild("Audio") ~= nil then
v.Audio:Play()
audio = true
end
game.Players.LocalPlayer.Character.Humanoid.Running:Connect(function()
animTrack:Stop()
if audio == true then
v.Audio:Stop()
end
end)
end
end)
end
end
Any help would be appreciated! Thanks.

2 comments
make a loop
where