I’m making a 2.5D obby and I want to implement D-Pad movement because most people with thumb sticks have stick drift and so I wanted a way for them to play without worrying about uncontrollable movement. I don’t know the right script for it though.
So I placed this script as a Local a script and put it into the StarterPlayerScripts:
local UserInputService = game:GetService(“UserInputService”)
local player = game.Players.LocalPlayer
local function onInput(input, gameProcessed)
if gameProcessed then
return
end
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.DPadUp then
print("DPAD Up Pressed")
player.Character:Move(Vector3.new(0, 0, -1))
elseif input.KeyCode == Enum.KeyCode.DPadDown then
print("DPAD Down Pressed")
player.Character:Move(Vector3.new(0, 0, 1))
elseif input.KeyCode == Enum.KeyCode.DPadLeft then
print("DPAD Left Pressed")
player.Character:Move(Vector3.new(-1, 0, 0))
elseif input.KeyCode == Enum.KeyCode.DPadRight then
print("DPAD Right Pressed")
player.Character:Move(Vector3.new(1, 0, 0))
end
end
end
UserInputService.InputBegan:Connect(onInput)
Exauce John B. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.