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

How do I move a part from one position to another smooth and "look natural"?

Asked by
ElBamino 153
3 years ago
Edited 3 years ago

Hey scriptinghelpers, sorry to bother you all with a question. I've been looking at tutorials and other questions but I just don't understand really. I don't know anything about this but, It seems to me there's a lot of different ways to accomplish this I suppose. Basically I'm trying to move a parts position while making it look natural and smooth. Below you will find the current code I'm using which is a Vector3.new, and it's like right in your face fast. Doesn't really pop like I want I want too. Basically I want it to float up nice and smooth and I'm not sure how to accomplish that without changing the vector for every single stud.

This is a script inside of a part.

The script I ended up with that works!

local tweenservice = game:GetService("TweenService")
local leviathan = script.Parent.Position
local tweeninfo = TweenInfo.new(
    30,
    Enum.EasingStyle.Quad,
    Enum.EasingDirection.InOut,
    0,
    true,
    0
)
local posend = Vector3.new(44,0,-116)
local tween = tweenservice:Create(game.Workspace.Leviathan, tweeninfo, {Position = posend})
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if message == "TEH EPIK DUCK IS COMING!!!" then
            tween:Play()
        end
    end)
end)

I appreciate the help in advance, I'm only here to learn! Thanks again.

1 answer

Log in to vote
1
Answered by
Jo1nts 134
3 years ago
Edited 3 years ago

Hello! If you want to accomplish a smooth positional change you will have to use TweenService it works on parts too!-- not just GUIs. Or you could use repeat to move the part's vector. Here's what the Tweening method would look like!

 local TweenService = game:GetService("TweenService")
 local tweenPart = script.Parent.Position

local startPos =  Vector3.new(44,0,-96)
local endPos = Vector3.new(44,-100,-96)

local tweenInfo = TweenInfo.new(60, -- time the tween takes
 Enum.EasingStyle.Quad, --kind of tweeting effect
 Enum.EasingDirection.InOut) -- type doesn't really matter

local tween = TweenService:Create(tweenPart, tweenInfo, endPos}

Tween:Play()

If the script doesn't function or contains a bug a comment is all that is required-- I have not tested this in studio.

0
Can you go back to startPos with TweenService? Back and forth (up and down in my case). ElBamino 153 — 3y
0
On line 11 there is a error in Output that says Unable to cast to Dictionary. I don't actually know what it's suppose to look like since this would be my first time using TweenService. ElBamino 153 — 3y
1
Alright, I think I got it figured out I did some more reading and testing myself. I'm going to provide the script I ended up with for future reference if anyone else needs it. Thanks for the help again (this is the second time!) Jo1nts! ElBamino 153 — 3y
Ad

Answer this question