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

How to set the camera for the player the same as it was?

Asked by 8 years ago

So at the beginning of the game I make the camera rotate around a part. I change the camera a few times while you're creating your character. After that I need to set the camera back to the way it was. Here is the camera script that makes the camera rotate around a part,


camera = game.Workspace.CurrentCamera camera.CameraSubject = game.Workspace:WaitForChild("FocusHere") camera.CameraType = "Scriptable" camera.FieldOfView = 60 num1 = 0 while true do camera.CoordinateFrame = game.Workspace:WaitForChild("FocusHere").CFrame * CFrame.Angles(math.rad(0),math.rad(num1),math.rad(0)) * CFrame.new(0,5,7)----------(RIGHT,UP,BACKWARDS) num1 = num1 + 1.5 wait() end

Now I need to make the camera follow the player the way it was before rotating around the part. How would I do this? This is what I tried,

local plr = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
camera.CameraSubject = plr.Character:WaitForChild("Head")
camera.CameraType = "Follow"-- make the camera normal again
camera.FieldOfView = 50--I would like this to be like this but if that's not posible that would be okay.

camera.CoordinateFrame = plr.Character:WaitForChild("Head").CFrame

Making the cameraType "Follow" doesn't work the way it normally does. It makes it so the player can look through solid parts and I DO NOT want that. I've also set the cameraType to "Custom" but that didn't work. It works better but the player can still see through parts. Any help is appreciated.

2 answers

Log in to vote
0
Answered by 8 years ago

Try something like this:

game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
game.Workspace.CurrentCamera.CameraType = "Follow" -- Change to the Camera Type you want

You can read more on this here:

http://wiki.roblox.com/index.php?title=Camera_manipulation

0
So just set the CameraSubject to the Humanoid... Thanks!!! User#11440 120 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

put this in a local script

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

Answer this question