How can I make a free roam camera script such as the one in studio or the one in trouble in terrorist town when you’re spectating?
There used to be a way to do it by removing the player’s character, but that doesn’t work anymore. Using UserInputService you can track when the player is pressing buttons (like the arrow keys, or WASD) and move the camera manually along the appropriate axes. If the CameraType is set to Custom it will still let you rotate it with the mouse.
Scripting Support is not a venue to ask for free code. Please reformat your question, try searching around for similar questions or attempt this yourself first.
One thing you’ll need to know, at the very least, is that whatever you do will involve manipulation of the CurrentCamera.
I actually remember writing code for this in a reply to a different post:
Lucky for you, I’m almost always passing out free code in Scripting Support!
You could set the cameraFocus and character to nil and then do some scripting to move the camera in different directions.
You could even use Camera:ScreenToPointRay to take into account the tilt of the camera.
Thank you for the code! If anybody is looking at this post to see how to do it and notice the camera is inverted just replace the 2 lines where Enum.UserInputType.MouseMovement is.
x = (x + (input.Delta.X*-1) * math.pi/180)%(2*math.pi)
y = math.clamp(y + (input.Delta.Y*-1) * math.pi/180,math.rad(-89),math.rad(89))
Sorry about that! I tested this script on a mousepad, so I didn’t notice!
Let me just modify that reply real quick…