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

How do I tween a unionated part?

Asked by 9 years ago

I'm currently trying to make my own FPS gun kit/engine and I'm running into a few issues. First off, I'm having trouble with tweening a few parts. The parts that I'm trying to tween are the (This is an M4) Bolt which is a union, and tween the mag. I'm having issues with this and I'm about to blow up. How do I get these dang things to tween smoothly like in Phantom Forces?

0
The thing is.. I've tried a few things but I haven't had any luck. Then I was told.. "Nothing here is gonna work" So I decided to come here and see if someone can give me some pointers. iDev_Percy 45 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

Like SandlineTactical said, sadly there are no ways to tween parts. But there are ways to get around this. You see, roblox has added built in objects/functions for each type of class of objects (e.x. Tweening and GUI, BodyMover's and Parts).

Since we're focusing on physical objects (parts), we'll use a BodyMover to smoothly animate the parts.

--Specificly, we'll use BodyVelocity to control what direction we want to move that object and how fast that movement will be.

Now the only thing that's left is to change the Velocity in a certain axis, in a certain sequence, to simulate an animation.

But let's say your more used to tweening than you are BodyMover's? How would you format a sequence (animation), but with the 4 arguments that are always within a tween?

--Let's break this problem down into a couple parts:

1) Since tweening is a function, we'll create a custom function to run specific lines of code.

2) Each argument in the tween itself will be the following:

--The starting position

--The ending position

--The increment for how much the object will cover

--The how frequent will the increment be aplied (to it's position)

The final product should look like:

Part = workspace.Part
OverLoad = false

function Tween(part,start,end,increment,time)
    if Part:FIndFirstChild(¨BodyVelocity¨) == nil then
        Instance.new(¨BodyVelocity¨,Part).Velocity = Vector3.new(0,0,0)
    end
    Part:WaitForChild(¨BodyVelocity¨)
    OverLoad = true
    wait()
    OverLoad = false
    local Rate = start - end * Vector3.new(time/increment,time/increment,time/increment) --quote me if I´m wrong on this part

    local LoopStatus = true
    Part.BodyVelocity = Rate
    while LoopStatus == true do
        if Part.Position == end then
            Part.BodyVelocity = Vector3.new(0,0,0)
            LoopStatus = false
        end
        if OverLoad == true then
            Part.BodyVelocity = Vector3.new(0,0,0)
            LoopStatus = false
        end
    end
end
0
At least it's a start. Thank you for helping me! Like I said, I'm really new to scripting but I can do the basics. I am not familiar at all however with tweening. :/ Please teach me. iDev_Percy 45 — 9y
0
Oh :3 . Since your new to scripting, you might want to ignore most of what I´m saying (first learn most of the basics in Lua), and then come back to this topic again later. LateralLace 297 — 9y
0
Though ill be willing enough to still give you the script :/. If you think you can understand enough of the coding terms I´m using, then you can start asking questions. LateralLace 297 — 9y
0
I know all the basics. I'm at the intermediate level now but I just started a month and a half ago so. iDev_Percy 45 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Apologies, but > tweening can only be done to GUI's. My only suggestion is to use CFrames or the roblox animation editor.

0
Okay how exactly do I use the CFrame? Can you give me an example? Say there's a part in the workspace called Part1 and we needed to move it backwards and then back fowards but like.. Smoothly. How exactly is this done? iDev_Percy 45 — 9y
0
Use the lerp method of the CFrame userdata. http://wiki.roblox.com/index.php?title=CFrame#Methods Spongocardo 1991 — 9y

Answer this question