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

How to make a whole model move?

Asked by 4 years ago
Edited 4 years ago

So here's what I tried to do: Making a PrimaryPart and doing this:

while true do
    script.Parent.PrimaryPart.Position = script.Parent.PrimaryPart.Position - Vector3.new(0,0,1)
    wait(0.5)
end

5 answers

Log in to vote
0
Answered by 4 years ago

Use :SetPrimaryPartCFrame() wich moves the model ignoring collisions, or use :MoveTo() method to move it withOUT ignoring collisions, wich means if it collides it will search for a free space to use, here is an example with :SetPrimaryPartCFrame method

local model = workspace.YourModel
local positionGoal = Vector3.new() -- must be a vector3, it can be the position of another part

-- if the model has a primary part then

model:SetPrimaryPartCFrame(CFrame.new(positionGoal)) -- moves with a converted cframe
--[[
Something you need to know,
SetPrimaryPartCFrame can rotate the model, with CFrame.Angles , etc
]]

With :MoveTo Method

local model = workspace.YourModel
local positionGoal = Vector3.new() -- must be a vector3, it can be the position of another part

-- if the model has a primary part then

model:MoveTo(positionGoal) -- needs Vector3,
--[[
Something you need to know,
MoveTo method doesn't rotate the part, but it doesnt ignore collisions
]]

So what are you trying to do is

while wait(0.5) do -- you can do this too instead of while true
    script.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.PrimaryPart.Position - Vector3.new(0,0,1)) 
end

You dont use PrimaryPart, because that only moves the part, it only moves the entire model if not anchored and it must be welded, thats because SetPrimaryPartCFrame and MoveTo exist

If this helped you, please mark this as answered!

0
All of the code that you put in helps me! User#29913 36 — 4y
0
This is going to be in my big game: The Walk Of Emotes User#29913 36 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

https://developer.roblox.com/en-us/api-reference/function/Model/SetPrimaryPartCFrame should tell you most of the info about it

aka you have to use a function

0
that is not an answer, that is a comment SteamG00B 1633 — 4y
0
aka means also know as maumaumaumaumaumua 628 — 4y
Log in to vote
0
Answered by
SteamG00B 1633 Moderation Voter
4 years ago
Edited 4 years ago

So you also need to make sure that the parts within the model are welded to eachother, otherwise, it'll only move the PrimaryPart.

local part = script.Parent.PrimaryPart
while wait(0.5) do --you can also have the loop with a wait like this
    part.CFrame=part.CFrame:Lerp(CFrame.new(Vector3.new(0,0,1),Vector3.new()))
end

You will want to use CFrame:Lerp() to move a CFrame from one point to another smoothly.

If this answers your question, then mark it as the accepted answer.

Log in to vote
0
Answered by 4 years ago

Models should have a MoveTo function -- Lookup models on the wiki for more info

0
That is also a comment, not an answer SteamG00B 1633 — 4y
Log in to vote
0
Answered by
cegberry 432 Moderation Voter
4 years ago

So to do this, a efficient process without using SetPrimaryPartCFrame with floating point accuracy errors, you would have a part that will be your model’s root, with all parts welded to that root part, make sure the weld method is using WeldConstraints. Make sure every part in your model is unanchored, but leave the root anchored, then to tween, you would apply TweenService:Create onto the root part.

Here’s a dev forum thread regarding the question: https://devforum.roblox.com/t/introduction-to-tweening-models/315253

Answer this question