How would I make a line of code within a tween goal that would set the new position equal to the old position minus 10 in the Y-direction?
3 Likes
If it helps:
local part = script.parent
local TweenService = game:GetService("TweenService")
local Position = part.Position
local info = TweenInfo.new(
2, -- Time animating
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- Repitions
false, -- Reverse post tween?
0 -- Delay time
)
local goal = {
Position = Position(1,1,1) -- help
}
2 Likes
You can set it equal to the part’s position plus some offset vector:
local part = script.parent
local TweenService = game:GetService("TweenService")
local Position = part.Position
local info = TweenInfo.new(
2, -- Time animating
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- Repitions
false, -- Reverse post tween?
0 -- Delay time
)
local goal = {
-- HERE
Position = part.Position + Vector3.new(0, -10, 0) -- adds minus 10 Y to the old position
}
8 Likes
Thank you, this worked when I put it in another tweenservice script, but the one I’m working on now is suffering from an unrelated issue since I’m trying to move a model instead of a part. Any idea on how to fix?
local crusher = script.parent
local TweenService = game:GetService("TweenService")
local Position = script.parent.Position
local crushinfo = TweenInfo.new(
2, -- Time animating
Enum.EasingStyle.Linear, -- EasingStyle
Enum.EasingDirection.Out, -- EasingDirection
0, -- Repitions
false, -- Reverse post tween?
0 -- Delay time
)
local crushgoal = {
Position = crusher.Position + Vector3.new(0, -10, 0)
}
local crush = TweenService:Create(crusher, crushinfo, crushgoal)
wait(5)
crush:play()
1 Like
Unfortunately, you can’t apply tweens to entire models.
Here’s a community tutorial showing a way to get around this if you’d like to check it out:
Introduction to Tweening Models - Resources / Community Tutorials - DevForum | Roblox
1 Like
Thanks, will be using that weld method