How can I check if a player is walking in my game? I am wanting to play an animation when a player is walking. Let me know how I can do it.
Here is my script:
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character
local PlayAnim
UIS.InputBegan:connect(function(input)--When a player has pressed LeftShift it will play the animation and it will set the normal walking speed (16) to 35.
if input.KeyCode == Enum.KeyCode.C then
Character.Humanoid.WalkSpeed = 11
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://10410199944'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
if input.KeyCode == Enum.KeyCode.ButtonX then
Character.Humanoid.WalkSpeed = 11
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://10410199944'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()
end
end)
UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.C then
Character.Humanoid.WalkSpeed = 17.5
PlayAnim:Stop()
end
if input.KeyCode == Enum.KeyCode.ButtonX then
Character.Humanoid.WalkSpeed = 17.5
PlayAnim:Stop()
end
end)
This script is in StarterCharacterScripts btw.
Thanks for your help!
Sincerely,