My script isn’t working and I have no idea why, this is supposed to run at the beginning of the game, no errors or anything. Anyone know why? (I tested it and the print runs)
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera
local CameraPosition = game.Workspace.Beginning
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = CameraPosition.CFrame
print("Done")
You need to include something like a wait(2) at the very beginning of the script since running a script right when the server starts can sometimes result in the script erroring out, because sometimes the script will run BEFORE the server is actually fully loaded, so things like stuff in workspace may not be fully loaded in yet.
Edit: It may take longer than 2 seconds to load, it all depends on your game’s size and the client’s speed.
When your character loads into the game, I’m pretty sure that the camera is reset so that it focuses on the character. Either wait for the character to load using .CharacterAdded or use .RenderStepped to overwrite the camera on each frame until you no longer need it.
I don’t believe you can use playeradded or characteradded functions in a local script, and have them function the same way, since the script will load after the player, causing it to not fire until their character is loaded a second time, or until another player loads the game.
Now, you could achieve it with just using waitforchild on a part of the character, or any methods listed above.
You can always detect when your character is added on the client, even if you cant due to yielding (wait functions in the script prior to the line being run) you can always check if the character already is in game and run a given function.
@Bloxrrey use Player.CharacterAdded in a localscript
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera
local CameraPosition = game.Workspace.Beginning
Camera.CameraType = Enum.CameraType.Scriptable;
repeat wait() until Cam.CameraType == Enum.CameraType.Scriptable;
Camera.CFrame = CameraPosition.CFrame
print("Done")