Whenever I join the game, I can’t seem to get the camera to update to the given CFrame coordinates.
Info
This is a local script that I’ve put into StarterGui. It’s meant to be for when the player joins the game only.
Code
local Player = game.Players.LocalPlayer
if not Player.Character then
Player.CharacterAdded:Wait()
end
local Scene = workspace:WaitForChild("Scene")
local SceneFocus = Scene:WaitForChild("SceneFocus")
local ScenePosition = Scene:WaitForChild("ScenePosition")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(ScenePosition.CFrame.p, SceneFocus.CFrame.p)
Nope there’s no errors, I don’t know what the issue is. If I wait 3 seconds however then it fixes the problem. I think the issue could be that the script runs everything before it’s able to load?
If that’s the problem though idk how to fix I tried
Hm I’m not sure how it worked for you, because it’s not working for me at all even in StarterPlayerScripts. I added prints, and it seems to print everything below it so I know the script can do other stuff afterwards.
well the main reason why cframe wont update is because the camera hasn’t loaded in yet(pretty sure why). Have you even tried it yet? Stopping any code from erroring/not working is a workaround technically
I changed the name earlier to Scene for this thread it just sounded more accurate. But in the game it’s named Menu so that’s not the solution.
I just updated the code though so this is what it looks like now:
local Player = game.Players.LocalPlayer
if not Player.Character then
Player.CharacterAdded:Wait()
end
local Scene = workspace:WaitForChild("Scene")
local SceneFocus = Scene:WaitForChild("SceneFocus")
local ScenePosition = Scene:WaitForChild("ScenePosition")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(ScenePosition.CFrame.p, SceneFocus.CFrame.p)
local Gui = script:WaitForChild("Menu")
local Play = Gui:WaitForChild("Play")
local GameLogo = Gui:WaitForChild("GameLogo")
Gui.Parent = Player.PlayerGui
GameLogo.Rotation = -20
Gui.Enabled = true
local Player = game.Players.LocalPlayer
repeat task.wait() until game:IsLoaded() or workspace.CurrentCamera ~= nil
local Scene = workspace:WaitForChild("Scene")
local SceneFocus = Scene:WaitForChild("SceneFocus")
local ScenePosition = Scene:WaitForChild("ScenePosition")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(ScenePosition.CFrame.p, SceneFocus.CFrame.p)
local Gui = script:WaitForChild("Menu")
local Play = Gui:WaitForChild("Play")
local GameLogo = Gui:WaitForChild("GameLogo")
Gui.Parent = Player.PlayerGui
GameLogo.Rotation = -20
Gui.Enabled = true
Tried this already, just did it again it doesn’t seem to do anything. Here’s the code:
local Player = game.Players.LocalPlayer
repeat task.wait() until game:IsLoaded()
local Scene = workspace:WaitForChild("Scene")
local SceneFocus = Scene:WaitForChild("SceneFocus")
local ScenePosition = Scene:WaitForChild("ScenePosition")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(ScenePosition.CFrame.p, SceneFocus.CFrame.p)
local Player = game.Players.LocalPlayer
repeat task.wait() until workspace.CurrentCamera ~= nil
local Scene = workspace:WaitForChild("Scene")
local SceneFocus = Scene:WaitForChild("SceneFocus")
local ScenePosition = Scene:WaitForChild("ScenePosition")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CFrame.new(ScenePosition.CFrame.p, SceneFocus.CFrame.p)
I tried that too, I’m not sure what the issue is the script just doesn’t want to load the cframes unless I wait 3 seconds for some reason. But I don’t want it to wait 3 seconds it’s unreliable and everyone loads in at different speeds.