Camera move with Mouse

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Basically, I want the camera to move with the player’s mouse in a smooth way, but I don’t know how to do so. I’ve tried making some scripts, but don’t know exactly how to.

  2. What is the issue? Basically, the issue is that even when I’ve tried doing the Part Orientation is based on the Mouse Y position, it’s just doesn’t works. The script is down below.

  3. What solutions
    have you tried so far?
    I’ve looked for solutions, but didn’t find.

-- Variables (Parent)
local PlayBut = script.Parent.Play
local SettingsBut = script.Parent.Settings
local ShopBut = script.Parent.Shop
local CreditsBut = script.Parent.Credits
local Middle = script.Parent.Parent.Middle
local Right = script.Parent.Parent.Right
local Camera = workspace.CurrentCamera
local SceneCam = workspace.Scene.CameraScene
local Player = game.Players.LocalPlayer
local Mouse = game.Players.LocalPlayer:GetMouse()

-- Variables (Boolean)
local settingsOn = false
local playOn = true -- Default: true
local shopOn = false
local CreditsOn = false

-- Variables (Services)
local RunService = game:GetService("RunService")

-- Objects to control visibility
local playObjects = {Middle, Right} -- Add the objects you want to control visibility here
local settingsObjects = {} -- Add the objects you want to control visibility here
local shopObjects = {} -- Add the objects you want to control visibility here
local creditsObjects = {} -- Add the objects you want to control visibility here

-- DefaultCam 
repeat 
	Camera.CameraType = Enum.CameraType.Scriptable
	wait(1)
until Camera.CameraType == Enum.CameraType.Scriptable

Camera.CFrame = SceneCam.CFrame

Mouse.Move:Connect(function()
	print('Moved!')
	SceneCam.Orientation = Vector3.new(0, Mouse.Y, 0)
	print(SceneCam.Orientation)
end)

Someone please help me with that, I would be so happy if someone did.
robloxapp-20230623-1817177.wmv (1.7 MB)

Basically, I want the camera to follow the mouse but has a limit.

3 Likes

Maybe this topic can help you with your situation?

3 Likes

menu_camera.rbxl (46.6 KB)

just wrote this for you.

2 Likes

Thank you so much! It’s worked.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.