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

Tried changing a model's PrimaryPart position to change all part positions, didnt work?

Asked by 4 years ago

Basically, I tried moving every part inside a Model by setting a part inside of it to its PrimaryPart, and tried changing its position with a script. I tried changing the part's Position to the Position of a part named "location" inside Workspace. Anyone know how to fix?

Here's the script:

local debounce = false

script.Parent.Touched:Connect(function(part)
    local isHuman = part.Parent:FindFirstChild("Humanoid") -- Checks if a player has touched the part. 
    if isHuman then 
        if not debounce then 
            debounce = true 

            local clone = game.ServerStorage.car:Clone() -- makes a Clone of the model 
            clone.Parent = workspace -- This works 
            clone.mainPart.Position = workspace.location.Position -- the "mainPart" is the PrimaryPart of the model, and I tried changing its position to the position of a part named "location" inside Workspace. It changed the position correctly, but the other parts didnt change with it. 

            wait(3)
            debounce = false
        end
    end
end)
0
could welding the parts together fix this? User#28017 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Use Model:SetPrimaryPartCFrame(). It will set the PrimaryPart to a certain CFrame and move the rest of the model based on the PrimaryPart's orientation and position.

local Model = Car:Clone()

Model:SetPrimaryPartCFrame(CFrame.new(0,0,0))

Model.Parent = workspace

https://developer.roblox.com/api-reference/function/Model/SetPrimaryPartCFrame

0
thx, this really helped me out! User#28017 0 — 4y
Ad

Answer this question