New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do I make every player's camera face a certain direction?

Asked by 1 year ago

In my game, when players are teleported to a level, their cameras don't face forward, so there comes times where they are completely turned around when the level begins. I simply want to turn everyone's camera to a certain coordinate, (0,90,0) for example. I understand that there was an update for ROBLOX studio that rearranged the contents in 'Player', so I would like an up to date solution for this problem.

0
CFrame(position Vector3, look at Vector3) is all you need to make a CFrame at a position looking towards the other vector position kingdom5 5726 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

I figured it out. The trick is to give every player a local script that turns their camera. I used an "in pairs" for loop to cycle through every player currently in the game and copy the local script into their character scripts, like so (the local script is named 'Turn'):

--this code goes in a normal script. for i,v in pairs (game.Players:GetChildren()) do script.Turn:Clone().Parent = v.character wait() end

Once the players have the local script, it will turn their cameras immediately. 'Turn' holds this simple code:

workspace.CurrentCamera.CFrame = CFrame.Angles(0,90,0)

Ad

Answer this question