I want to restrict xbox movement to left and right like how you would do on pc but i just don’t know how i could do it. I want it to be exactly like how it would be on PC if i just disabled W and S but for xbox joysticks
it is, but i got it figured out, you kinda have to remake it for Xbox
heres the new script i made
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local moveSpeed = 8 -- Adjust as needed
local deadZone = 0.2 -- Define the dead zone threshold
-- Function to handle both PC and Xbox inputs
local function handleMovement()
local moveDirection = Vector3.new(0, 0, 0)
-- Handle Gamepad input
for _, input in ipairs(UserInputService:GetGamepadState(Enum.UserInputType.Gamepad1)) do
if input.KeyCode == Enum.KeyCode.Thumbstick1 and math.abs(input.Position.X) > deadZone then
moveDirection = Vector3.new(input.Position.X * moveSpeed, 0, 0) -- Move left and right
end
end
-- Handle Keyboard input
if UserInputService:IsKeyDown(Enum.KeyCode.A) or UserInputService:IsKeyDown(Enum.KeyCode.Left) then
moveDirection = Vector3.new(-moveSpeed, 0, 0)
elseif UserInputService:IsKeyDown(Enum.KeyCode.D) or UserInputService:IsKeyDown(Enum.KeyCode.Right) then
moveDirection = Vector3.new(moveSpeed, 0, 0)
end
humanoid:Move(moveDirection, true)
end
UserInputService.InputChanged:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.Gamepad1 and input.KeyCode == Enum.KeyCode.Thumbstick1 then
local moveVector = input.Position
if math.abs(moveVector.X) > deadZone then
humanoid:Move(Vector3.new(moveVector.X * moveSpeed, 0, 0), true) -- Move left and right
end
end
end)
RunService.RenderStepped:Connect(handleMovement)