I'm not very experienced but i wanted to try to get a camera script to make the camera to be a kind of sidescrolling camera, so I looked at a tutorial from the developer hub and copied the scripts, but i realized that the script for some reason only made it so that the camera could follow you when you move right and it also slowly moved behind you when you kept moving, so I decided to change some things. I tried to just set it so that the camera's x position was the same as the player's, but it doesn't seem to be working. How do I fix it?
local cameraHeight = 12
local cameraZOffset = 20
local cameraSpeed = .25
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')
wait(1)
local function setupCamera()
camera.CFrame = CFrame.new(Vector3.new(player.Character.HumanoidRootPart.Position.X,cameraHeight,cameraZOffset),Vector3.new(0,cameraHeight,0))
end
setupCamera()
player.CharacterAdded:Connect(setupCamera)
RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value)

2 comments
It seems like the camera is actually moving with the player now, but it for some reason also rotates the view in the opposite direction of where i'm moving. Also I had the wait in there because i figured I may be having problems because i hadn't given the player enough time to load into the game.
Well, I fixed your original problem. If you want another answer for your second, go ahead and make another question.