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
