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 put a player's camera back to themselves after changing it?

I'm making a camera manipulation intro to my new game and I'm honestly puzzled on this. This is the current script I have:

local cam = workspace.CurrentCamera local camPart = workspace:WaitForChild("Cam")

cam.CameraType = Enum.CameraType.Scriptable cam.CFrame = camPart.CFrame + cam.CFrame.lookVector * 2 cam.CameraSubject = workspace:WaitForChild("Cam") camPart.Transparency = 1

(Cam is the part I'm using for my camera) how would I change it back to humanoid?

2 answers

✓ Accepted answer

You can reset the camera back to the character by doing this:

if game.Players.LocalPlayer.Character then
	cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end
cam.CameraType = Enum.CameraType.Custom

It first checks if the character exists. Then, it sets the camera subject to the corresponding humanoid. Finally, it sets the camera type to custom (this allows the player to choose their own camera mode). You may change this if you had a setting for the CameraType before.

2 comments

0

Thanks so much man! I'm making a "Robloxity" Remake and I needed this for the intro =D

0

Mans are grinding.

the way you can do this is by first setting the camera subject and then the cameratype back to custom.

local cam = workspace.CurrentCamera 
local camPart = workspace:WaitForChild("Cam")

cam.CameraType = Enum.CameraType.Scriptable 
cam.CFrame = camPart.CFrame + cam.CFrame.lookVector * 2 
cam.CameraSubject = workspace:WaitForChild("Cam") 
camPart.Transparency = 1

delay(5,function()
	cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
	cam.CameraType = Enum.CameraType.Custom
end)

So this basically did everything you did in the script above (please use codeblocks) and makes a coroutine 5 seconds after the

cam.CameraType = Enum.CameraType.Scriptable 
cam.CFrame = camPart.CFrame + cam.CFrame.lookVector * 2 
cam.CameraSubject = workspace:WaitForChild("Cam") 
camPart.Transparency = 1

runs. In the coroutine, it makes the player the camera subject and makes the camera type "custom"

3 comments

0

Also, I might be wrong about the delay function creating a coroutine, but I'm just basing that off a RobloxU tutorial by StickMasterLuke 4 years ago

0

It's not called a coroutine; it's called a function. Coroutines are just an implementation detail here.

0

is there a link?

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