Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Position is not a valid member of Model?

Hello, the issue is on line 27 and despite it being a part it keeps returning the error "Position is not a valid member of Model".

I'm trying to make a auto-generating track.

Problem Code:

	newMiddle.Position = Vector3.new(mainMiddle.Middle.Size.X/2,0,0) 
+ middle.Finish.Position
-- And its the " Vector3.new(mainMiddle.Middle.Size.X/2,0,0) " part
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local mapsFolder = ReplicatedStorage:WaitForChild("Maps")
local maps = mapsFolder:GetChildren()

local lobby = game.Workspace:WaitForChild("Lobby").Lobby

maxLength = 10
local mainMiddle = mapsFolder.Middle


for i = 1, maxLength do
	local middle = mapsFolder.Middle:Clone()
	middle.PrimaryPart = middle.Start
	middle.Parent = game.Workspace.Track
	middle.Finish.Transparency = 1
	
	local nextMiddle = game.Workspace.Track:FindFirstChild("Middle2")
	if nextMiddle == nil then
		local newPosition = Vector3.new(lobby.Size.X/2,0,0) + lobby.Position
		middle:MoveTo(newPosition)
	else
		local theMiddle = game.Workspace:FindFirstChild("Middle"..i-1)
		local newPosition = Vector3.new(theMiddle.Size.X/2,0,0) + theMiddle.Position
		middle:MoveTo(newPosition)
	end
	
	local newMiddle = mainMiddle:Clone()
	wait(1)
	newMiddle.Position = Vector3.new(mainMiddle.Middle.Size.X/2,0,0) + middle.Finish.Position
	newMiddle.Parent = game.Workspace.Track
	newMiddle.Name = "Middle"..i
end

3 comments

0

The reason is because Models don't have the position property

0

You can't set the position of a model.

0

You can however use :SetPrimaryPartPosition with the model's priary part to make it move

3 answers

The only way to find a position of a model is model:GetPrimaryPartCFrame(), but it’s not returning a centre of a model, and you have to set primary part of a model (a part with “RootPart” in its name is a primary part of a model by default).

This discussion is preserved as it was. New answers, comments, and votes are closed.