Bug or scripting error

I have been trying to get this gui to up down but it keeps going up Its not even letting me set the position after I tween it :confused:
this is where it ends up
https://gyazo.com/0e75eba954362671fbcf4df41b5dcdf9
this is where its supposed to go
https://gyazo.com/709a364a1248743fd93e9a6618a2258b
local tweenS = game:GetService("TweenService") local info = TweenInfo.new(1,Enum.EasingStyle.Linear) script.Parent:TweenPosition(UDim2.new(script.Parent.Position.X,0.978, 0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,1)

it ends up at 0,0 instead of 0.978,0

Sorry about first post, I thought it was a part.

So, there is 1 error.

  1. UDim2 has 4 values, 2 scale, 2 offset.

Here’s how you can fix yours:

script.Parent:TweenPosition(UDim2.new(script.Parent.Position.X.Scale, 0, 0.978, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 1)

Hopefully this helped!

It did not work and I know tween service is not supposed to be there

I updated the script above. I forgot to add script.Parent.Position.X.Scale

Use this:

script.Parent:TweenPosition(UDim2.new(script.Parent.Position.X.Scale, 0, 0.978, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 1)
3 Likes

YAS it worked thank you very much

3 Likes

Yeah, no problem, man.

I have a tip for you. When you’re scripting, use the output box if you don’t already. It provides useful information about an error if you get one.

You can activate it in the View tab.

1 Like

This is misinformation. The TweenPosition and TweenSize functions are for convenience, not because TweenService doesn’t work.

3 Likes

Fixed my first post. Sorry, I didn’t see what it sounded like. Obviously TweenService is used for UI’s.

And more.

Example (though not related to OP):

This has already been posted and there was a suggestion earlier, indirectly, that you realistically shouldn’t use these methods.

Use TweenService instead.

I never said that TweenService didn’t work, I was giving base code that if OP desires, they can improve on. If theses methods shouldn’t be used, then why do they exist? Its just a quality of life code improvement. TweenService/TweenPosition/TweenSize all work exactly the same. Unless there is an official / credible post about how its inefficient, I won’t be editing my answer. Using the TweenPosition function is simple and easy to understand.

Even the wiki uses it:

local object = script.Parent
object.AnchorPoint = Vector2.new(0.5, 0.5)
object.Position = UDim2.new(0, -object.Size.X.Offset, 0.5, 0)
wait(2)
object:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))

As far as I know, there is no easy way to stop a tween animation using :TweenPosition. TweenService is quite easy to understand and it can you keep your code neat. With tweeninfo, you don’t need to keep repeating code and specifying your easing direction and style, unlike :TweenPosition. Nothing is wrong with :TweenPosition though, and it is really up to OP on what he prefers.

1 Like

Never said anything about how you mentioned TweenService doesn’t work. TweenService can do everything these methods can and more. Typically it’s in your best interest, especially if you want to modify multiple properties in one tween, to use this.

There are many methods that shouldn’t be used yet they exist. The existence of a method doesn’t imply that it should be used. Furthermore, method usage is case dependent.

TweenService and the isolated GuiObject tweens look the same but internally they aren’t. TweenService has much more capability and support over these methods which by now are considered legacy and could be deprecated in the foreseeable future. They may be kept for compatibility purposes.

I don’t really know why you’d want to wait for an official post before taking a recommendation, but that’s on you I guess. Members out here are just looking to help users.

As for the blog, what post are you reading from? The blog doesn’t necessarily have updated information and TweenService did not exist at the time of those two methods. The Developer Forum and Hub contain the most updated information about development practices. The blog is primarily for Roblox news, not development updates. This separation is already very clear.

2 Likes

I misunderstood what you were quoting, to me it looked like you quoted posatta because you thought that I said TweenService didn’t work.

I agree that “There are many methods that shouldn’t be used yet they exist” however, some methods are created for quality of life simple script creation, in my answer I wanted the OP to understand the script first, before making it as efficient as possible because sometimes making everything as efficient as possible isn’t the best approach when explaining something (not implying that TweenService is necessary hard). Usually official posts like from a Roblox Engineer confirm inefficiency. I rather keep everything again as simple as possible instead of being efficient. I want people to learn not just copy and paste scripts from the devforum, not understanding what the code does.

Yeah sorry, I meant the wiki / developer hub.

I appreciate your feedback, I was just going off the top of my head and what I heard and saw, thanks for confirming / debunking my answer!

If you want to talk about this further, I think we should move it this into messages.

I forgot to mark this post closed sorry, I fixed it now!