Hello!
So, I’m making an obby and it has stages. Whenever a player dies, they are teleported back to that stage. I don’t know how to change their camera rotation because it is turned in the opposite way as they should continue the obby.
How would I do that?
Could you possibly make the camera’s CFrame, it’s position with the lookAt being the character’s HumanoidRootPart’s LookVector?
For example:
local player = game:GetService("Players").LocalPlayer
local camera = workspace.CurrentCamera
camera.CFrame = CFrame.new(camera.CFrame.Position, player.Character.HumanoidRootPart.CFrame.LookVector)
Since it’s using the LocalPlayer, it has to be a LocalScript.
Where you put it is up to you really, I’d prefer StarterCharacterScripts since it’ll run when they spawn.
Ok. Did it, but it turns the camera only sometimes, not always.
Oh, I put the wait() above the code and it seems to be working now, but, is there any other way to fix that problem?
In Robloxs template obby it doesnt use a spawn location just like yours and uses a decal to indicate its a checkpoint and uses a script inside it in which if u touch it you now spawn there. You can find it if you go on studio and click + new then All Templates then Obby
Thank you so much!
Optional thing: is there any way to make the camera to be a little bit above the character, not behind it. And also, it’s not really centered.
For that you’d need to change the CFrame to the HumanoidRootPart’s CFrame + some offset.
You’ll get the Orientation from the HumanoidRootPart’s CFrame by doing this.
For example:
wait()
local player = game:GetService("Players").LocalPlayer
local camera = workspace.CurrentCamera
local humanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
camera.CFrame = humanoidRootPart.CFrame * CFrame.new(0, 2, 1) --// 2 Y axis offset + 1 Z axis offset