Position is not a valid member of model

I am trying to get the model to spawn at a random position in the map instead of always at the center. I am using this but when I try to run it, it returns the error shown in the title.

Code is below:

Model:PivotTo(Vector3.new(math.random(-200, 200), Model.Position.Y, math.random(-200,200)))

Thats because a model doesnt have a Position.
Try to define the Position of the model by using a part thats in the model.

Models doesnt have the property “Position”, you need to use get a basepart position or a primarypart position.

I’m pretty sure to pivot a model, it requires a CFrame, not a vector! Also, models don’t have a position property (That’s why Model.Position.Y doesn’t work) Try this:

-- Set the primary part of the model to some part!
local TheX = math.random(-200, 200)
local TheY = Model.PrimaryPart.Position.Y
local TheZ = math.random(-200, 200)
local PositionVect = Vector3.new(TheX, TheY, TheZ)
	
-- Turns Position Vector into CFrame
Model:PivotTo(CFrame.new(PositionVect))

:GetPivot() gives you to the CFrame of the Model, :PivotTo() Allows you to change its CFrame.

1 Like

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