#how would i go about checking player movement

19 messages · Page 1 of 1 (latest)

vivid solar
#

i was wondering how i could check if a player is walking for an elif statementdfgbdbvfhvddbf

outer yew
vivid solar
#

mmm thank you ill try it out

hallow sedge
#

u can use cframe moved if u want a event

jaunty sage
#

if Humanoid:GetState() == Enum.HumanoidStateType.Running then

vivid solar
jaunty sage
#

char.Humanoid

#

character

vivid solar
#

hmm wont work

#

this is the entire code btw

local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character


UIS.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        if Character.Humanoid:GetState() == Enum.HumanoidStateType.Running then
               Character.Humanoid.WalkSpeed = 25
             local Anim = Instance.new('Animation')
             Anim.AnimationId = 'rbxassetid://nuh uh'
             PlayAnim = Character.Humanoid:LoadAnimation(Anim)
             PlayAnim:Play()
            
        end
        
    end
end)

UIS.InputEnded:connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftShift then
        Character.Humanoid.WalkSpeed = 16  
        PlayAnim:Stop()
    end
end)
#

i got it to work like this ```
local UIS = game:GetService('UserInputService')
local Player = game.Players.LocalPlayer
local Character = Player.Character

UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
if Character.Humanoid.MoveDirection.Magnitude > 0 then
Character.Humanoid.WalkSpeed = 25
local Anim = Instance.new('Animation')
Anim.AnimationId = 'rbxassetid://15194215737'
PlayAnim = Character.Humanoid:LoadAnimation(Anim)
PlayAnim:Play()

    end
end

end)

UIS.InputEnded:connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
Character.Humanoid.WalkSpeed = 16
PlayAnim:Stop()
end
end)

#

but if i stop walking but still hold shift it keeps running the animation

#

hmmm

#

ill have to write a loop that checks for movedir ?

vivid solar
#

i can change if -> while ?

blazing schooner
#

Where is the script located?

vivid solar
#

oh sorry hello, its in starterplayer -> startercharacterscripts

#

got it to work thanks everyone