Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I disable Camera scrolling and Camera collisions?

In one of my games, I've managed to lock the camera to an object using the following script:

-- Located in game.StarterPlayer.StarterPlayerScripts

local Cam = game.Workspace.CurrentCamera
local ThePlayer = game.Players.LocalPlayer

function SetCam(status)
	Cam.CoordinateFrame = CFrame.new(10,10,10)
	Cam.CameraSubject = game.Workspace.MenuCenter
	Cam.CameraType = 3
	Cam.FieldOfView = 40
	ThePlayer.CameraMaxZoomDistance = 16
	ThePlayer.CameraMinZoomDistance = 8
	print("MenuCamera has been "..status)
	if status == "set" then
		local MoveGui = script.CameraReset:Clone()
		MoveGui.Parent = game.Players.LocalPlayer.PlayerGui
	else end
end

game.Players.PlayerAdded:connect(SetCam("set"))
game.Players.LocalPlayer.PlayerGui.CameraReset.ImageButton.MouseButton1Click:connect(SetCam("reset"))

Yet, the Player is still able to zoom over the limits designated, and the camera is able to 'clip' through blocks instead of avoiding camera obstructions.

When run for the first time, both lines 20 and 21 read: Attempt to connect failed: Passed value is not a function.

The reset button currently doesn't work either and returns the following: Attempt to call a nil value.

Although I may be able to figure that out myself. Feel free to ask if I didn't make myself clear on anything and thanks for the help. :D

1 answer

I'm not sure what the errors are about yet, but I can tell you how to prevent the player from interfering with the camera.

The game inserts a script into the player upon joining called 'CameraScript' in the player's child 'PlayerScripts'. You can remove this script, which will prevent the player from controlling the camera in any way.

And if you want, you can re-script the zooming in and out to make sure it fits your desired bounds.

This discussion is preserved as it was. New answers, comments, and votes are closed.