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

How to restore a Player Camera to Default?

I've made a camera script, so that when you click a part it sends a signal to client to change your camera to view a part. (Security Cameras Basically) And when you click again you're returned to your Avatar. However, when I do this the player model doesn't turn transparent in 1st person, and you can move your camera through walls. Advice is greatly appreciated!

-- This is in a LOCAL Script
local RepS = game:GetService("ReplicatedStorage")
local Remote = RepS.Remote
local CameraEvent = Remote.CEvent

local ViewingCharacter = true

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

CameraEvent.OnClientEvent:connect(function(Camera)
	local Cam = workspace.CurrentCamera
	local Character = workspace[Player.Name]
	
	Cam.CameraSubject = Camera
	Cam.CameraType = Enum.CameraType.Custom
	ViewingCharacter = false
	
	local ActiveCamera = function()
		if ViewingCharacter then return end
		if not Character:FindFirstChild("Head") then return end
		Cam.CameraSubject = Character.Head
		Cam.CameraType = Enum.CameraType.Custom
		ViewingCharacter = true
	end
	
	Mouse.Button1Down:connect(ActiveCamera)
end)

3 comments

0

The camera subject for default is actually the humanoid.

0

^ CameraSubject = Character.Humanoid

0

Thanks!

1 answer

✓ Accepted answer

This code resets the camera to what it default is on.

game.Workspace.CurrentCamera.CameraType = "Custom"
	
game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid 
	
game.Workspace.CurrentCamera.FieldOfView = 70

1 comment

0

Thank you so much!

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