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

How to make a TextLabel move based on Experience to next level?(TweenSize)

I'm well aware It has something to do with tweensize as far as knowledge goes, but what I cannot figure out is how to get the value of the current experience you may have gamed in a game, and have the experience war resized based on how much experience you have until the next level.

1 answer

You could use the TweenSize function specific to GUI objects, but I personally like to stick with TweenService. (here's the wiki page on TweenService)

So, there's one function, Create that requires 3 parameters. The Instance you want to tween, the TweenInfo for the the instance in question and a table containing the properties you want to tween.

All in all, it should look a little like:

local TweenService = game:GetService('TweenService')

TweenService:Create(
	bar,
	TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out),
	{
		Size = UDim2.new(currentXp / xpRequired, 0, 1, 0)
	}
):Play()

Hopefully the arguments passed are pretty self-explanatory! Of course, you could store the tween created in a variable to be played every time the player's experience changes.

1 comment

0

I did get this to do somewhat of what I wish to work with, but it doesn't give off enough of a push to the bar,I am in understanding that it has something to do with the size of x,y,z, but if I were to say change the value to 10, then change it to 20, the bar I should hope should double the amount, instead it divides,

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