How would I make this group of parts move from its position?

I have a group of parts that move. I want it to move up 1 and then wait(1) and go down 1.

This just moves the parts to these positions.

How would I make it so that the parts slowly float up and down from its position?

local model = script.Parent

while wait(1) do
	model:MoveTo(Vector3.new(0, 1, 0))
	wait(1)
	model:MoveTo(Vector3.new(0, -1, 0))
end
1 Like

First you need to choose a main part in the model and weld all the other parts to it. Then there is a property in the model called PrimaryPart, and set that to the main part. Then move the primary part and it will move the whole model.

The edited script:

local model = script.Parent

while wait(1) do
	model.PrimaryPart:MoveTo(Vector3.new(0, 1, 0))
	wait(1)
	model.PrimaryPart:MoveTo(Vector3.new(0, -1, 0))
end
1 Like

TweenService might come in handy, it’s a very powerful tool for animations!

Since you will be Tweening a model, I recommend reading this.
Introduction to Tweening Models - Resources / Community Tutorials - DevForum | Roblox

2 Likes

I’ll check it out now. Thank you

This doesn’t work on meshes apparently in models?

  16:24:08.325  MoveTo is not a valid member of MeshPart "Workspace.testVillian.leftEar.primary"  -  Server - Script:4
  16:24:08.325  Stack Begin  -  Studio
  16:24:08.325  Script 'Workspace.testVillian.leftEar.Script', Line 4  -  Studio - Script:4
  16:24:08.325  Stack End  -  Studio

Don’t use “:MoveTo” I don’t think it’s very good, just set the position to whatever.

Something like this:

local model = script.Parent

while wait(1) do
	model.PrimaryPart.Position = Vector3.new(0, 1, 0)
	wait(1)
	model.PrimaryPart.Position = Vector3.new(0, -1, 0)
end

The only issue with this is that it doesn’t move smoothly in a linear like way

Sorry I just realised what you need:

local part = workspace.Part -- set this to the part you want to move
local ts = game:GetService("TweenService")
local timeToMove = 1 --you can change this if you like

while wait(timeToMove) do
	local t1 = game:GetService("TweenService"):Create(part, TweenInfo.new(timeToMove), {Position = part.Position + Vector3.new(0, 1, 0)})
	t1:Play()
	wait(timeToMove)
	local t2 = game:GetService("TweenService"):Create(part, TweenInfo.new(timeToMove), {Position = part.Position + Vector3.new(0, -1, 0)})
	t2:Play()
end

Assuming that wouldn’t go into a ServerScript inside the part because the GetService

There are two versions of MoveTo, one of them takes in a vector3 position and just sets the primarypart of a model’s position to that vector3(its almost exactly the same as just setting the position directly), the second version is humanoid:MoveTo where it forces the humanoid to move in a certain directly relative to the walkspeed for this however I believe TweenInfo comes in handy

local model = modelPath
game.TweenService:Create(modelPath.PrimaryPart,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingStyle.InOut,math.huge,true,0,{Position = model.PrimaryPart.Position+Vector3.new(0,1,0)}):Play()```
1 Like

If you wish to move a group of parts linearly,

I would once again recommend reading this.

what do you mean? (minimum message size)

Ill explain this tweeninfo has many hidden properties some developers don’t know abbout and here is a list of them

TweenInfo.new(
    1, --time it takes for the tween to happen
    Enum.EasingStyle.Sine, --the easing style you can read about the different kinds here https://developer.roblox.com/en-us/api-reference/enum/EasingStyle
    Enum.EasingDirection.InOut, --Direction of the tween more about it here https://developer.roblox.com/en-us/api-reference/enum/EasingDirection
    math.huge, --How many times this tween should repeat (math.huge is infinite)
    true, -- whether or not this tween will reverse itself and the tween properties(if true then it will reverse and since the repeat time is infinite itll keep revering over and over like you want)
    0--delay between each tween
)```
1 Like

*like it wouldnt go into a script like this in workspace
image

i still dont understand. what do you mean “it wouldn’t go into a script”?

like LocalScript or ServerScript

i swear i dont know what the means. are you asking if it goes into a local or server script?
btw it goes in serverscript

TweenService or :GetService can be called on both the server and client, however some services like serverstorage are locked to the server

yes, it is in a ServerScript but thats why I’m wondering.

because im geting this even after i tried local

GetsService is not a valid member of DataModel "Game" - Server - Script:2