I'm working on a relatively basic movement system for the player, where holding down the Z key puts them in a skating mode. However, while testing I've noticed that pressing another key in WASD to change direction, or alternatively using any of the arrow keys, will cause the player to stop moving all together. This makes movement very inconvenient for keyboard players who would have to rely on dragging the camera and pressing a single WASD key at a time. Any help in fixing this code will be appreciated!
#Certain keys stop movement
1 messages · Page 1 of 1 (latest)
im curious. you have idle set to true initially. what does the idle variable trigger in your script?
also inside your idle function, you haven't grouped the conditions properly. put () around the 2nd set of or conditions in both the if and elseif that way lua can read them properly
--Idle
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if humanoid.MoveDirection.Magnitude > 0 and (walking == true or sprinting == true or skating == true) then
idle = false
elseif humanoid.MoveDirection.Magnitude == 0 and (walking == false or sprinting == false or skating == false) then
idle = true
end
end)