Camera Manipulation Help

I want to make a players camera to view a car but it isn’t working.
I have disabled CharacterAutoLoads because I don’t want their character to spawn but then I realised that the gui doesn’t load, so I put this script in Workspace:

game.Players.PlayerAdded:Connect(function(player)
	player:LoadCharacter()
	player.Character:Destroy()
end)

Then I have a local script in StarterPlayerScripts that should change the camera to view the car but it’s not working:

local camera = game.Workspace.CurrentCamera
local player = script.Parent.Parent

game.Players.LocalPlayer.CharacterAdded:Connect(function()
	wait(player.Character == nil)
	camera.CameraType = Enum.CameraType.Attach
	camera.CameraSubject = game.Workspace:WaitForChild("Red Car")
end)

Does anyone know why this isn’t working?

You do realize you could just reference the player as game.Players.LocalPlayer, right…? Also Server Scripts run the moment the server first starts, so as soon as a player joins the game I’d assume that the PlayerAdded event would run first (Also why are you adding a boolean to a wait() statement I am confuzzled)

local camera = game.Workspace.CurrentCamera
local player = script.Parent.Parent

game.Players.LocalPlayer.CharacterAdded:Connect(function()
	wait()
	camera.CameraType = Enum.CameraType.Attach
	camera.CameraSubject = game.Workspace:WaitForChild("Red Car")
end)

You could try adding a wait(1) before you go ahead & destroy the character, or wait for the Character’s appearance to fully load or something

game.Players.PlayerAdded:Connect(function(Player)
    Player:LoadCharacter()

    Player.CharacterAppearanceLoaded:Connect(function(Character)
        Player.Character:Destroy()
    end)
end)

I’ve tried that and it doesn’t work, now it spawns the character but doesn’t delete it and the camera is still not working.

The character script always worked and the gui appeared after the script functioned. It’s just the camera that isn’t working.

I didn’t even see that the first script wasn’t the main issue

Are you sure you couldn’t just, not even have the CharacterAdded event?

local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer

wait()
camera.CameraType = Enum.CameraType.Attach
camera.CameraSubject = game.Workspace:WaitForChild("Red Car")

That didn’t work, it still does the same thing. :face_with_raised_eyebrow:

Printing…?

print("This should at least work")
local camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer

print("We got our variables")

wait()
print("Changing the Camera Properties")
camera.CameraSubject = game.Workspace:WaitForChild("Red Car")
camera.CameraType = Enum.CameraType.Attach

It prints everything including Changing the Camera Properties but it’s still not working.

Try setting the camera type to Scriptable before changing any properties of it.

The camera doesn’t need to be set to scriptable because I’m not scripting it to do anything, I’m just changing the camerasubject.

In the properties of the camera in workspace when I test the game, it says that the camerasubject is the red car and the cameratype is attach which is strange… It should be working.

Weird, it works completely fine on my side

The only potential thing that I could see, is that the Red Car isn’t replicated across the client side cause it worked when I did it

What do you mean by

The Red Car is a model so I wonder if that makes a difference?

Not sure, you could try changing the “Red Car” to a part instead perhaps? I did a Part & it worked fine for me

I’m not exact if the CameraSubject only accepts “specific” Instance values

It has to be scriptable or else camera subject cannot be called lol

CameraSubject can be changed even if it isn’t scriptable actually. It’s only if you’re tweeting the camera or something.

@Jackscarlett This still does the same thing, I’m not sure why it isn’t working…

It’s really strange because… well, look:

Try setting the CFrame to the primary part times like 50 so

cam.CFrame = Car.PrimaryPart.CFrame * 50

I’m not sure what this would change but it prints an error saying Players.Wildcutepenguin.PlayerScripts.CameraScript:7: invalid argument #2 (Vector3 expected, got number).

If you go to Camera | Roblox Creator Documentation on the DevHub, it says “You can configure the Camera to follow a Model by setting the CameraSubject to the model’s Model.PrimaryPart.”

CFrame cannot be multiplied. Also, is the camera subjected to a part or a model? If it is a model, does the model have a primary part?

If red-car is a model, then please change it to camera.CameraSubject = workspace:WaitForChild("Red Car").PrimaryPart or workspace:WaitForChild("Red Car"):FindFirstChildWhichIsA("BasePart")