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
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
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
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
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()```
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
)```