local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local UIS = game:GetService("UserInputService")
local Mouse = Player:GetMouse()

local MaxXAxis1 = 0
local MaxXAxis2 = 1919

local Head = Character:WaitForChild("Head")

repeat 
	Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable


local function UpdateCam(inputType, gps)
	if not gps and inputType.UserInputType == Enum.UserInputType.MouseMovement then
		if inputType.Position.X >= MaxXAxis1 and inputType.Position.X <= MaxXAxis2 then
			print("\tPosition:",inputType.Position)
			Camera:Interpolate(Head.CFrame, Mouse.Hit, .1)
		end
	end
end

UIS.InputChanged:Connect(UpdateCam)

I'm trying to basically have the camera follow the mouse a bit, like seen in Menu GUI's, are you guys aware of anyway I could achieve this? I've tried interpolating the camera but this is glitchy and doesn't happen the way I want it to, any help?

8 comments

0

Why are you looping at line 12 to change the CameraType? no loop needed

0

Sometimes it does not set the CameraType so I do this as a failsafe.

0

Wouldn't the repeat loop also pose a risk for crashing as there's no yield?

0

no, not really as it only does this until the CameraType gets set to Scriptable, sometimes the script may run before the player spawns in hence the repeat loop until it is set

0

Maybe create function that tracks the mouse as it moves, using the center of the screen as a reference. Connect the function to renderstep to update every frame

0

I heard of this magical setting called First Person

0

First Person isn't doing it the way I want to though.

0

is the camera anchored to a point or is it free(as if it can move around freely)?