Help with CFrame positioning with a model

Hello!
I’m trying to teleport a model to a certain location in my game. I’m curious how to go about doing this successfully, In my “Locations” is a Folder with a CFrame Value and a StringValue with the position of where I want it to be teleported to. The “model” Has an NPC, Model, and a Union. I don’t think that will matter but, figured I’d add it just in case. If you’re able to help, thank you! If not, I hope the rest of your day goes great!

wait(5)
local Locations 	= game.ServerStorage.WarehouseNPCLocation:GetChildren()
local Location
local model	 		= workspace.WarehouseClaim

Location = Locations[math.random(1,#Locations)]
model:SetPrimaryPartCFrame(tonumber(Location.Position.Value))

(if I can provide something more to help you, please let me know I’d be happy to do so!

Do you have a reason for the CFrameValue and StringValue? If you want the position maybe just use a Vector3Value?

I just figured that would be the best way to do so. I’ll try a Vector3Value now. Would it still be model:SetPrimaryPartCFrame?

local Locations = game.ServerStorage.WarehouseNPCLocation:GetChildren()
local model	= workspace.WarehouseClaim

Location = Locations[math.random(1,#Locations)]

model:SetPrimaryPartCFrame(CFrame.new(Location.Value))

If you want to easily add orientation then I suggest using a part to represent the location.

Then you could just replace that line with this!

model:SetPrimaryPartCFrame(Location.CFrame.p)

I got this error in the output.

"Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.

With this code:

local Locations 	= game.ServerStorage.WarehouseNPCLocation:GetChildren()
local Location
local model	 		= workspace.WarehouseClaim

Location = Locations[math.random(1,#Locations)]

model:SetPrimaryPartCFrame(CFrame.new(Location.Value))

In your model properties you need to select a primary part.

Screen Shot 2020-04-27 at 10.29.06 PM
Screen Shot 2020-04-27 at 10.29.29 PM

When using :SetPrimaryPartCFrame you have to change the model property to the part you wish to be the primary.

Ohh! Thank you so much! I got it working.