How do i move everything with the primary part?

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

image

Hi, make the tycoon a model and then move it with the pivot point.

model:PivotTo(something:GetPivot() or vector3.new(posX,posY,posZ))

You should always use PivotTo when moving models.

Model:PivotTo(x) -- replace x with a CFrame

Setting the primary part’s CFrame / Position only moves itself, not the rest in the model.

1 Like

Could i do the same thing with rotation?

CFrame also covers rotations (orientation)

Model:PivotTo(CFrame.New(Position) * CFrame.Angles(math.rad(X), math.rad(Y), math.rad(Z)))
-- or you can do
Model:PivotTo(TargetPart.CFrame) -- TargetPart is a part where you want the model to pivot to
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.