Is there something wrong with this tween script? It doesn't play for me (There is no error in the output, and my past tweens have been successes)

Hi, I’m trying to tween a gun, it’s called the FMG9 and it’s supposed to pop out, but for some reason, my tween isn’t working? Here is the tween script:

local tween = game:GetService(“TweenService”)
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local info1 = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)
local goal = {Position = script.Parent.Parent.Parent.Parts.Stuff.Flip1.Position}
local goal1 = {Position = script.Parent.Parent.Parent.Parts.Stuff.Stock1.Position}
local tween1 = tween:Create(script.Parent.Parent.Parent.Parts.Stuff.Flip, info, goal)
local tween2 = tween:Create(script.Parent.Parent.Parent.Parts.Stuff.Stock, info1, goal1)
script.Parent.OnServerEvent:Connect(function()
if script.Parent.Parent.Parent.Values.Flipped.Value ~= true then
tween1:Play()
tween2:Play()
script.Parent.Parent.Parent.Sounds.Flip:Play()
wait(1)
script.Parent.Parent.Parent.Values.Flipped.Value = true
end
end)

What it looks like:
image
What it’s supposed to fold into:

Instead, it just stays like the original, no errors in the output.

5 Likes

Try replacing the order of the EasingDirection and EasingStyle.

2 Likes

Didn’t work, thanks for trying though.

Is your part anchored or unanchored?

Unanchored, but welded to the handle.

Are you tweening the handle? 30chars

no, I’m tweening the body and grip (which is actually the real gun’s handle but isn’t the actual thing named handle)

Need more info. Does the sound play? Maybe add some prints inside the connected function to see if it actually ever called. Tweens look fine. The function is either never called or does not pass the if.

1 Like

Yes, the sound plays, but the animation does not play.

I’ve tried printing, it works, I just don’t know what’s wrong with the lerp :C

Can you screenshot the object explorer so I can understand the hierarchy better?

1 Like


image

Ok I googled the gun and it looks like the unfolding is performed with rotation. However you seem to only animate position. Do the end parts (Flip1, Stock1) have rotation or just position differences?

1 Like

They have rotation too D: 30chars
I’ve used lerp for a long time, and this is probably the reason why… I’m really new to tweening because I don’t like the long process of tweening

Add that to your goal.

local goal = {
       Position = script.Parent.Parent.Parent.Parts.Stuff.Flip1.Position,
       Orientation = script.Parent.Parent.Parent.Parts.Stuff.Flip1.Orientation
}

Similar for goal1. Also check if other properties might need animating.

1 Like

Alright, I hope this works. 30CHARS!!!

Sorry, it still doesn’t work, just stay still and solid :C

Protip: If you want to let the default values in TweenInfo then you don’t need to specify them so:

local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0)

can become:

local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)

Also what is this 30 chars thing?

So you know how roblox requires comments to be 30 characters long to prevent spam? Well since my thing isn’t 30 characters long, I add 30charssssssss to make it 30 characters.

Hmm, is Flip1 and Stock1 always in the correct place but invisible?