Player movement left and right

hello guys, I’m a beginner in this world of game creation, I would like to receive help from someone, I wanted to know how I can make a movement similar to subway surfers, I’ve spent hours and hours trying to reproduce this movement but unfortunately I couldn’t, I left an example video in case you have doubt, thank you very much for your attention

Alright this seems pretty simple. I don’t have enough time give an example, but you can use Humanoid MoveDirection to Move the character on the X,Z Axis.

1 Like

Use CFrame to change position of your model/character.
And UserInputService to track player input.

Example:

-- LOCAL SCRIPT
local uis = game:GetService("UserInputService")

local plr = game.Players.LocalPlayer -- our player
local character = plr.Character or plr.CharacterAdded:Wait() -- our character, we are using "CharacterAdded" event to get character in case if "plr.Character" is nil.

local function movement(input, gameProcess)
if gameProcess then return end -- code below wont run if we are pressing keys in chat
   if input.KeyCode == Enum.KeyCode.A then -- Checking if player pressed the A key
      local currentCFrame = character:GetPivot() -- our current CFrame
      local nextCFrame = currenctCFrame * CFrame.new(-3,0,0) -- change -3 to any number you want, it just shows how far you will move in X axis (Left)
      character:PivotTo(nextCFrame)
   end
      if input.KeyCode == Enum.KeyCode.D then -- Checking if player pressed the A key
      local currentCFrame = character:GetPivot() -- our current CFrame
      local nextCFrame = currenctCFrame * CFrame.new(3,0,0) -- change 3 to any number you want, it just shows how far you will move in X axis (Right)
      character:PivotTo(nextCFrame)
   end
end

uis.InputBegan:Connect(movement) -- Connecting our function to InputBegan event
5 Likes

try using path find service or humanoid:MoveTo()

1 Like

thank you very much, it worked perfectly

1 Like