Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I reset the camera of a player?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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()
0
It works! Thanks! ChipioIndustries 454 — 9y
0
No problem! :) Orlando777 315 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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")

Answer this question