Teleporting a model

I’m trying to make it where a script will pick a random model from a folder and then will teleport that model.

local CarFolder = game.ReplicatedStorage.Cars

local items = CarFolder:GetChildren()
local randomItem = items[math.random(1, #items)]
randomItem:Clone().Parent = game.Workspace
randomItem:SetPrimaryPartCFrame(script.Parent.CFrame)

Up above is what I have so far and is a script located in a part. I don’t know what went wrong and studio isn’t giving me and errors. Thanks.

Local clonedRandomItem = RandomItem:Clone()

clonedRandomItem:SetPrimaryPartCFrame(script.Parent.Cframe)
clonedRandomItem.Parent = game.Workspace

You just changed cfframe of orginal car not cloned one in workspace

Every time u clone something set cloned thing to variable so when u want reference to clonned thong ull be able to, otherwise u reference to orginal

SetPrimaryPartCFrame is deprecated, you should instead use PivotTo

1 Like