Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't the TweenPosition function working like it should in my script?

I am trying to make a box fly onto the screen with tween position.

I have recently run into an error that has puzzled me for quite some time now and after multiple attempts to fix my script, I decided to ask you guys on scripting helpers why my script isn't working the way it should.

Here is my script,

script.Parent.Position = UDim2.new(0.25,0,1,0)
script.Parent:TweenPosition(UDim2.new(0.25,0,.25,0), "Quint", "In", 2)

As you can see, this script is a child of the object I want to animate, a frame, but instead of it working I get this error,

20:21:09.874 - Unable to cast string to token
20:21:09.875 - Stack Begin
20:21:09.876 - Script 'Players.Player1.PlayerGui.MACROS.login.box.Starter', Line 2
20:21:09.877 - Stack End

I can't seem to figure out what this error message means so I am in need of help. Thanks.

1 answer

✓ Accepted answer

It's because you messed up on the EasingStyle and Direction. They aren't strings, they're values. Also, you put the Style parameter before the Direction parameter. It's the other way around.

script.Parent.Position = UDim2.new(0.25, 0 ,1 , 0)
script.Parent:TweenPosition(UDim2.new(0.25,0,.25,0), Enum.EasingDirection.In,  Enum.EasingStyle.Quint, 2)

This works.

Remember to accept the answer if it helped :)

2 comments

0

Thanks! I can continue on my GUI project. :)

0

No prob :D

This discussion is preserved as it was. New answers, comments, and votes are closed.