I've been trying to make a script that will Sprint and play the animation on the player pressing W twice. I am also having trouble trying to find out how to make the animation stop after the player is done holding the double W. I also need to know how to make the walkspeed and camera zoom go back to normal after the holding is lifted.
local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=4681457024"
local keyConnection = mouse.KeyUp:connect(function (key)
end)
local DoubleDebounce = false
local UserInputService = game:GetService('UserInputService')
local TargetKeyCode = Enum.KeyCode.W
UserInputService.InputBegan:Connect(function(input,gameEvent)
if not gameEvent and input.KeyCode == TargetKeyCode then
if not DoubleDebounce then
DoubleDebounce = true
spawn(function()
wait(1) --Interval of time where the player can double tap a key
DoubleDebounce = false
end)
elseif DoubleDebounce then
local playAnim = humanoid:LoadAnimation(anim)
playAnim:Play()
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (70+(i*2))
wait()
end
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 24
repeat wait () until false == false
DoubleDebounce = false
keyConnection:disconnect()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (80-(i*2))
wait()
end
end
end
end)

2 comments
Thank you so much you helped a ton!!
Accept his answer XenosAlt