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?
How do I tween a unionated part?
2 answers
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:
Since tweening is a function, we'll create a custom function to run specific lines of code.
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
4 comments
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.
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.
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.
I know all the basics. I'm at the intermediate level now but I just started a month and a half ago so.
Apologies, but > tweening can only be done to GUI's. My only suggestion is to use CFrames or the roblox animation editor.
2 comments
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?
Use the lerp method of the CFrame userdata. http://wiki.roblox.com/index.php?title=CFrame#Methods
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
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.