How would i go about making a character only able to move certain directions Ex: Left and or Right
2 Likes
What have you tried so far, and how did that work? Also make sure you search for similar topics, IIRC this has been covered before 
You need to first disable the player controls. You can do this using the following LocalScript under StarterGui:
local controls = require(game:GetService("Players").LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetControls()
controls:Disable()
Then, you need to bind each direction you want to be able to move in to a key separately.
char = game:GetService("Players").LocalPlayer.Character or game:GetService("Players").LocalPlayer.CharacterAdded:Wait()
humanoid = char:WaitForChild("Humanoid")
uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.A then
humanoid:Move(Vector3.new(1, 0, 0)) --Or whatever direction
elseif input.KeyCode == Enum.KeyCode.S then
-- ...
end
end
end)
Use a parallel event using InputEnded once they stop holding the key.
Hope this helps!
1 Like
I have already got it working sorry 