Setting Camera Subject to a Part Cloned to Workspace

This is a continuation of this thread:

Essentially, a plane in Workspace has an attachment in it, which the is the location of the Camera’s CFrame.

I’ve modified the solution given to me in that thread to where the plane and its attachment gets cloned to Workspace from ServerStorage. The plane also gets named after the player it is connected to. The issue is that the plane clones fine, but the camera fails to move itself to the attachment.

This is the code I have in the camera script so far. It is a LocalScript placed in StarterPlayerScripts.

local camera = workspace.CurrentCamera
local run = game:GetService("RunService")

local function player()
	local plane = game.Workspace:FindFirstChild(player.Name .. "Plane")
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CameraSubject = plane
	
	local function OnChanged()
		camera.CFrame = plane.CameraAtt.WorldCFrame
	end
	
	run.Heartbeat:Connect(OnChanged)
	
end

The script that clones the plane to Workspace is a normal script placed within ServerScriptService. (I previously had it in Workspace which also worked well)

The script does not throw any errors when the game is run.

nvm i found the solution

all i had to do was add wait(1)

1 Like