I have the tycoon spawning and teleporting the player to their tycoon but sometimes the tycoon doesn’t spawn at all and doesnt bring everything with it
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local TycoonTemplate = ServerStorage.Tycoon
local cframe
Players.PlayerAdded:Connect(function(player)
local PlayerTycoon = Instance.new("Folder")
PlayerTycoon.Name = player.UserId
PlayerTycoon.Parent = workspace.Tycoons
local tycoonSpawns = workspace.Tycoons.TycoonSpawns:GetChildren()
local randomTycoonSpawn = tycoonSpawns[math.random(1, #tycoonSpawns)]
if randomTycoonSpawn ~= nil then
cframe = randomTycoonSpawn.CFrame
end
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character.HumanoidRootPart
if randomTycoonSpawn.Occupied.Value == false then
randomTycoonSpawn.Occupied.Value = true
local newTemp = TycoonTemplate:Clone()
newTemp.Parent = PlayerTycoon
newTemp.PrimaryPart.CFrame = cframe
hrp.CFrame = newTemp.Tycoon.StarterBuild.Spawn.CFrame + Vector3.new(0, 5, 0)
newTemp.Tycoon.StarterBuild.CollectingPad.BillboardGui.TextLabel.Text = player.Name
end
end)
Players.PlayerRemoving:Connect(function(player)
local PlayerTycoon = workspace.Tycoons:FindFirstChild(player.UserId)
if PlayerTycoon ~= nil then
PlayerTycoon:Destroy()
end
end)
this is the spawn and the base how would i make it so everything is spawned together like how its supposed to