Help with Mouse Direction

How can I make the character to look left and right only? I’m not really good with CFrames so, I couldn’t figure it out myself. I only made it to follow the mouse. If someone could help, I would appreciate it.

--[[ SERVICES/VARIABLES ]]

local RunService = game:GetService("RunService")

local Player = game:GetService("Players").LocalPlayer

local Character = Player.Character

local Humanoid = Character:WaitForChild("Humanoid")

local mouse = Player:GetMouse()

--[[ FUNCTIONS ]]

   RunService.RenderStepped:connect(function()
    	if Humanoid.Health > 0 then
    		Character.LowerTorso.CFrame = CFrame.new(Character.LowerTorso.Position, Vector3.new(mouse.Hit.p.X,Character.LowerTorso.Position.Y, mouse.Hit.p.Z))
    	end
    end)
1 Like

you are trying to make a side scroller like super mario?

I’m making 2D game, and I want the player to be able look left and right with mouse.

roblox offers a starter map for such a game, i suggest looking over the scripts inside, it’s called side scroller

I’ll take look n see if that helps me, thanks.

I’ve look into it, not really the thing I’m looking for, I have everything ready, I just don’t know how to do mouse direction thingy if the mouse is on left side plr faces left and etc.

Maybe get the mouse.hit vectors like lookvector + right vector + upvector and mess around with that stuff!

I don’t really understand it, that’s why I’m asking for help, if that’s possible, I’m mainly a UI scripter. and never done this kind of stuff, so it’s my first time.

Mouse | Documentation - Roblox Creator Hub maybe this, could help. If it doesnt you should learn about vectors and cframes to get the knowledge of it.