I've been stuck on this for awhile and can't seem to find anything on this matter. I've been trying to play a sound during an animation (at the start of the animation) and can't seem to get it right, need any help I can get.
Here's the script I have for this:
wait(.5)
Player = game.Players.LocalPlayer.Character
animation1 = Player.Humanoid:LoadAnimation(script.Animation1)
animation2 = Player.Humanoid:LoadAnimation(script.Animation2)
animation3 = Player.Humanoid:LoadAnimation(script.Animation3)
CanEmote = true
game:GetService('UserInputService').InputBegan:Connect(function(Input, GameProcessed)
if not GameProcessed and Input.KeyCode == Enum.KeyCode.P then
local emote = math.random(1,3)
if emote == 1 and CanEmote == true then
animation1:Play()
CanEmote=false
wait(2)
CanEmote=true
elseif emote == 2 and CanEmote == true then
animation2:Play()
CanEmote=false
wait(2)
CanEmote=true
elseif emote == 3 and CanEmote == true then
animation3:Play()
CanEmote=false
wait(2)
CanEmote=true
end
end
end)
