local player = game.Players.LocalPlayer
-- Wait for the character to load
player.CharacterAdded:Wait()
print("added")
local car = workspace:WaitForChild("StarterCharacter")
local cam = workspace.CurrentCamera -- Get the current camera
-- Set camera properties
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = car-- Set the camera to follow the car
print("Camera set up completed")
for some reason the script only works on the studio, I edited it to be sure that the character is added first but still nothing changed.
even the prints does not works, I tried even to put a print statement in each line and nothing printed. I just get a red line of the script location in the StarterCharacterScripts and in the character.
you dont have to wait for character added. when you put the script in StarterCharacterScript it alway be cloned and parented to character. You should remove that line
(Also if that car is model i suggest you use car.PrimaryPart or something like body of the car)
local player = game.Players.LocalPlayer
local car = workspace:WaitForChild("StarterCharacter")
local cam = workspace.CurrentCamera -- Get the current camera
-- Set camera properties
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = car.PrimaryPart -- Set the camera to follow the car
print("Camera set up completed")
For some reason, the Player is sometimes added before this script is instantiated. So in order to factor this, you have to also check if the player exists in first place and then wait if it isn’t there yet.
if you have this script in starter character scripts then it won’t pass the line where it’s waiting for the character to be added since the event your waiting is already happened try to remove any yields