Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Running this function twice makes a player unable to move. Help please? {Solved}

function Crouch()
	CanJump = false
	Humanoid.WalkSpeed = Humanoid.WalkSpeed - 10
	print(RootJoint.C1)
	for i = 0, 1, 0.1 do
		RunService.RenderStepped:wait()
		RightHip.C1 = RightHip.C1:lerp(CFrame.Angles(0, 0, math.rad(30)) * CF(-0.5, 0, 0.5), i)
		LeftHip.C1 = LeftHip.C1:lerp(CFrame.Angles(0, 0, math.rad(-10)) * CF(0.5, 0, 0.5), i)
		RootJoint.C1 = RootJoint.C1:lerp(CF(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0), i)
		Humanoid.CameraOffset = Humanoid.CameraOffset:lerp(Vector3.new(0, -1, 0), i)
	end
end

The function works, but if the player is crouched and this function is run again, the player then acts as though the controller for this player has been removed. The player is able to jump, but not walk.

1 comment

0

For anyone who would like to see the complete animation. (Shhhhhh, I like showing off.) https://gyazo.com/864a65fa97169e37dad83e4dad86a3bb

1 answer

Solved the problem.

I was subtracting the 10 from the players current walkspeed. The player's speed was 16 subtract 10 now 6. Run that function again subtract 10 from 6 now their walkspeed is -4 hence the inability to move.

This discussion is preserved as it was. New answers, comments, and votes are closed.