Errors on Preloading assets

I’m trying to yield the thread until the data models plane and lScript are loaded in. It seems to be referencing my collection as a nil value though.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if not char:FindFirstChild("PlaneScript") then
			local lScript = script.PlaneScript:Clone()
			local plane = game:GetService("ServerStorage").Plane:Clone()
			plane.Name = char.Name.."'s Plane"
			plane.Parent = workspace
			lScript.Parent = char
			local collection = {lScript, plane}
			repeat wait() until collection:IsLoaded() -- This where error happens, it says collection is nil
			lScript.Disabled = false
		end
	end)
end)
1 Like

Fixed it by checking its state instead of its data model

1 Like