Recreating Classic Movement System

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A: i want to recreate the classic movement style.

  2. What is the issue? Include screenshots / videos if possible!
    A: while creating the script, i’ve found that 1 code snippet stopped working after multiple key presses and another one has a problem while holding the movement keys first before the boolean gets true.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    A: i’ve tried looking into the devforum, but my problem was a little specific

Hello, i’m new to the forum and i was thinking of creating a Obby game with some ragdoll and classic movement system recreated from scratch.

While i was creating the custom animation script, i’ve found that 2 snippets that have some problems and i can’t figure it out…

I’m kinda new to scripting so some of my scripts are basic.

First snippet:

rS.RenderStepped:Connect(function()
	if uis:IsKeyDown(Enum.KeyCode.Space) then
		resetCooldown()
	end
	
	print(tostring(jumpStop))
	
	if jumpStop then
		local current = tick()
		local elapsedT = current - last
		
		if elapsedT < .1 then
			loaded_animJump:AdjustSpeed(0)
			print("true")
		else
			print("false")
			loaded_animJump:AdjustSpeed(1)
			task.wait(loaded_animJump.Length - loaded_animJump.TimePosition - 0.05)
			canWalkAnim = true
			jumpStop = false
		end
	end

end)
  1. What it does?
    A: Simply resets the “last” variable to tick() to make it lasts longer and freezes the jump animation until when the Space key is not pressed.

  2. What is the error?
    A: When pressing the Space key multiple times, it stops working, no errors, no print outputs.

Second Snippet:

local function WalkAnimation()
	script.Parent:FindFirstChild("Humanoid").Running:Connect(function(speed)
		if speed < 1 then
			loaded_animWalk:Stop(0)
		else
			if not loaded_animWalk.IsPlaying and canWalkAnim then
				loaded_animWalk:Play(0, 10)
				print("is walking")
			else return
			end
		end
	end)
end
  1. What it does?
    A: Simply runs the walk animation while the player is moving, if not, it stops the animation.

  2. What is the error?
    A: While pressing one of the movement keys before the canWalkAnim sets to true, it causes to not play the animation, no print outputs.

If someone would help me solving these problems, i’ll be appreciated. :sweat_smile:

I’ll try to figure it out while there’s no answer.