local Animation = script.CrouchAnim
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local track = hum:LoadAnimation(Animation)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,proc)
if proc then
return
end
if input.KeyCode == Enum.KeyCode.E then
track:Play()
end
end)
Can someone tell me how I can get it so if I press E once the animation plays and when I press it again it stops.
This just makes it that everytime I press w,s,a, or d it plays the animation then when I press w,s,a, or d again it stops the animation
local Animation = script.CrouchAnim
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local track = hum:LoadAnimation(Animation)
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input,proc)
if proc then
return
end
if input.KeyCode == Enum.KeyCode.E then
track:Play()
end
if track.IsPlaying then
track:Stop()
else
track:Play()
end
end)
UIS.InputBegan:Connect(function(input,proc)
if proc then
return
end
if input.KeyCode == Enum.KeyCode.E then
if track.IsPlaying then
track:Stop()
elseif not track.IsPlaying then
track:Play()
end
end
end)