Play Screen glitches

Hello my name is Rocket and i want to make a Play Screen similar to this.

This is my issue that my mouse sensivity is to high so i want to add some boundaries but i have no idea how to do it.

I have tried many solutions but they dont result.

--//Variables
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

--//Camera Placement

cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(-51.222, 3.74, 57.362)* CFrame.Angles( math.rad(0, 108.52, 0))

print("Camera Switched")

--//Camera Moved

mouse.Move:Connect(function()
    cam.CFrame = CFrame.new(cam.CFrame.Position, mouse.Hit.Position)
end)

If somebody can help me on this mention me.

Divide the mouse position by 100 to decrease the sensitivity and use math.clamp on the vector’s components to describe a bounding box.

Im not that advanced but could you explain it? I was playing with CFrames

Here

--//Variables
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

--//Camera Placement

cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(-51.222, 3.74, 57.362)* CFrame.Angles( math.rad(0, 108.52, 0))

print("Camera Switched")

--//Camera Moved

mouse.Move:Connect(function()
local hit = mouse.Hit.Position
local x,y,z = hit.x/100,hit.y/100,hit.z/100
x,y,z = math.clamp(x,-2,2),math.clamp(y,-5,5),math.clamp(z,-2,2) -- you'll have to play with these to get what you want
    cam.CFrame = CFrame.new(cam.CFrame.Position, Vector3.new(x,y,z))
end)

You can also divide by a smaller number to increase the sensitivity.

1 Like

Thanks but i wanted to understand it because i just take the script
could you explain it?

1 Like

Well, you did most of the work already. The idea behind dividing by 100 is to make it so each change in the mouse position affects the camera less. Previously, each stud that the mouse moved would correspond to a change by 1 stud in the camera, dividing by 100, every 100 studs the mouse moves the camera will move 1.

When you use math.clamp, it returns a value between the minimum and maximum bounds provided, if x>max then x = max and if x<min then x = min.

Why you did it like this?
You could’ve just used Mouse.X and Mouse.Y (with ViewSizeY,ViewSizeX) and it would be easier! ;d

1 Like

How would that work? Its already working this would be the 4 time i rewrite it :C