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
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).
Use
Model:SetPrimaryPartCFrame(CFrame.new(pos))