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

How do I reset the camera of a player?

I'm creating a start screen, but when the player clicks 'Play' the camera doesn't reset like it's supposed to. There is no output, and the camera seems to be simply set free. What am I doing wrong?

local plr=game.Players.LocalPlayer
local cam=Workspace.CurrentCamera
local freezePosition=Workspace.StartCameraPart.CFrame
while script.Parent:findFirstChild("CamEnabled")==nil do wait() end
while script.Parent.CamEnabled.Value==true do
	cam.CameraType="Scriptable"
	cam.CameraSubject=nil
	cam.CoordinateFrame=freezePosition
	game:GetService("RunService").RenderStepped:wait()
end
cam.CameraType="Fixed"
cam.CameraSubject=plr.Character.Humanoid
cam.CoordinateFrame=plr.Character.Head.CFrame
script.Parent:remove()

2 answers

✓ Accepted answer

Let me know if this works

local plr=game.Players.LocalPlayer
local cam=Workspace.CurrentCamera
local freezePosition=Workspace.StartCameraPart.CFrame
while script.Parent:findFirstChild("CamEnabled")==nil do wait() end
while script.Parent.CamEnabled.Value==true do
    cam.CameraType="Scriptable"
    cam.CameraSubject=nil
    cam.CoordinateFrame=freezePosition
    game:GetService("RunService").RenderStepped:wait()
end
cam.CameraType="Custom"--Should be custom for the default player camera.
cam.CameraSubject=plr.Character.Humanoid
--cam.CoordinateFrame=plr.Character.Head.CFrame forget about this
script.Parent:remove()

2 comments

0

It works! Thanks!

0

No problem! :)

To make the camera just like it was before you changed anything:

worksapce.CurrentCamera.CameraType='Custom'
workspace.CurrentCamera.CameraSubject=game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

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