Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Position is not a valid member of Model?

Asked by
pilotly 15
4 years ago

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

0
The reason is because Models don't have the position property RazzyPlayz 497 — 4y
0
You can't set the position of a model. aadenboy 17 — 4y
0
You can however use :SetPrimaryPartPosition with the model's priary part to make it move CreationNation1 459 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago

Model doesn't have a Position property.

Ad
Log in to vote
0
Answered by 4 years ago

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).

Log in to vote
0
Answered by 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Use

Model:SetPrimaryPartCFrame(CFrame.new(pos))

Answer this question