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 9 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,

01camera = game.Workspace.CurrentCamera
02camera.CameraSubject = game.Workspace:WaitForChild("FocusHere")
03camera.CameraType = "Scriptable"
04camera.FieldOfView = 60
05 
06num1 = 0
07while true do
08    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)
09    num1 = num1 + 1.5
10    wait()
11end

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,

1local plr = game.Players.LocalPlayer
2local camera = game.Workspace.CurrentCamera
3camera.CameraSubject = plr.Character:WaitForChild("Head")
4camera.CameraType = "Follow"-- make the camera normal again
5camera.FieldOfView = 50--I would like this to be like this but if that's not posible that would be okay.
6 
7camera.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 9 years ago

Try something like this:

1game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
2game.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 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

put this in a local script

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

Answer this question