What my problem here is that when ever I hold down the S key, (it plays an animation) it constantly plays from the start which I find really annoying. I'm not sure how I'm going to do this.
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local humanoid = player.Character.Humanoid
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=3398376417"
local holdingSKey = false
UIS.InputBegan:Connect(function(inputObject)
if(inputObject.KeyCode==Enum.KeyCode.S)then
holdingSKey = true
while holdingSKey do
local playAnim = humanoid:LoadAnimation(anim)
playAnim:Play()
wait(0.2)
end
end
end)
UIS.InputEnded:Connect(function(inputObject)
if(inputObject.KeyCode==Enum.KeyCode.S)then
holdingSKey = false
end
end)
