How to force the player to move

Hello there!

My request, more specifically, is how to make the player ONLY move left and right, and make them unable to jump. (by left and right, I am referring to the A and D keys.)

I have zero scripting experience and could not find any tutorials, so I’m just hoping any of you could help.

Thanks for reading!

1 Like

sorry this won’t be much of a tutorial, but if you insert a local script into starter character scripts and put this code into that script, I think it should work.

local cam = workspace.CurrentCamera
local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")
local cas = game:GetService("ContextActionService")
cas:UnbindAction("moveForwardAction")
cas:UnbindAction("moveBackwardAction")
hrp.CanJump = false

game:GetService("RunService").RenderStepped:Connect(function()
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = cam.CFrame:Lerp(CFrame.new(hrp.Position + Vector3.new(0, 5, 15), hrp.Position), 0.1)
end)

I pasted the script, however I’m still able to jump. It worked perfectly otherwise because I couldn’t move up or down.

1 Like
local Humanoid = char:WaitForChild("Humanoid")

Humanoid.JumpPower= 0

You can add this to the script and it should work

1 Like

@42Spider_man42 @TheDCraft Your scripts are so easily bypass-able by an exploiter, it’s laughable.

local char = game:GetService("Players").LocalPlayer:FindFirstChild("Character")
repeat task.wait() until char 
char["LocalScript"]:Destroy() -- even if the name changes it can be viewed by something like dex, or you could just use a loop and delete them all
char.Humanoid.JumpPower = 50
char.Humanoid.CanJump = true
local c = game:GetService("ContextActionService")
c:BindAction("moveForwardAction", aFunction)
c:BindAction("moveBackwardAction", anotherFunction)

This is how easily an exploiter could bypass this, PLEASE use another solution instead

2 Likes

It’s incredible how you wrote a script to bypass someone else’s code and went straight to insulting them instead of actually writing a better solution. Lol

6 Likes

To be honest, since the forwards/backwards thing needs to come from the client, it’s almost impossible to do anything about it. You could keep on checking if the clients jump power gets modified and then just ban the player, but the only thing you can really do for the forwards and backwards thing is have a system where it automatically detects it on the server. (Which could be as simple as a part that follows the the players in front and behind of it and if it gets touched they get kicked. (But modified in a better way))

these solutions are viable if you make them server based
you could put those contextaction restrictions and do a server check to see if the rootpart velocity is moving on a restricted axis

you could also just deactivate the jumping humanoid state and do a servercheck to see if the character has entered a jumping humanoid state

Since some people apparently want to bypass a moving script, you could check to see if the X or Z axis of the player’s HumanoidRootPart changes too much. Now I don’t know your game’s anarchy, but if you implement a really strict rule like if the position changed by 0.0001, by any means Roblox’s movement could glitch and move the character left I suggest putting the limit at 2-3 studs.

Hey there! Yes I do apologize for that. I did not really have any time.

Just do what @seanieplays said and make them server sided.

You could also constantly set the players speed and jump power, or maybe just let them move lol