Tweening Problem

Basically, I am currently creating a game called Collecting Simulator, but I am not creating it for the fame or for money, my main objective over this game is to learn stuff like scripting and improve my other skills such as Building/UI Designing/Modelling/GFX/Animating.
I am using the DevForum as a learning resource since it’s easier for me to find talented people that could help me resolve my problem.

I am bad at scripting so yeah it’s an easy fix for some people.

My current problem is the tweening Billboard over a part. (Yes, I am using free modelled food but I am planning or re-making them by my self it’s just testing purpose)

My problem:
What I want: (of course tweened)


I want it so each time you click the food the UI will go down by 0.1

Thanks for helping!

Okay, so I see that you have a variable named TOTALCLICK, which counts how many times the food has been clicked. This could be a very useful value to use in this scenario.

To get the percentage that the food has been “eaten”, we can divide the current TOTALCLICK by the total amount it started with. For example:

local percentage = TOTALCLICK/10

So when it’s been clicked 5 times, percentage = 5/10 = 0.5 (half)

Simply make sure that the frame “main” is anchored from the left hand side, and each time the food is clicked you should tween it to be the same size as the percentage.

main:TweenSize(, 0, 0.8, 0), "Out", "Quad", .5, true)

This should be enough for the issue, you shouldn’t need to tween the position at all! :smiley:

EDIT: Just noticed you’d like the frame to start with 0.9 size on the X axis. In this case, simply multiply the percentage by 0.9 when tweening!

main:TweenSize( * 0.9, 0, 0.8, 0), "Out", "Quad", .5, true)
1 Like

The result is not what I wanted, what I wanted is that if you ever played pet simulator you know when pets go to the coins a bar will appear when the pets start petting I will say the coin, the bar will start to go from left to right. This is what I want to accomplish but you are making it look like a cooldown and this is isn’t what I wanted, unfortunately. You scripts worked but not how I wanted it to be.

What I want: this is what I want it to be I know you know how to make it but didn’t understand my concept.

I really need to fix it because it’s a big part of my game and I don’t want to mess it up. If there is something that isn’t clear please let me know.

I think this is something else in your code. I used this code:

local amount = 10

local main = script.Parent.BillboardGui.Back.Main

	amount = amount - 1

    -- add all the extra stuff like wait(1) etc

	main:TweenSize( * 0.9, 0, 0.9, 0), "Out", "Quad", .5, true)
	if amount < 1 then

Which I inserted as a script into the part. Here is the result I got, which I believe is similar to what you were asking for. If not, let me know what is wrong because I’m a little confused… :stuck_out_tongue:


I suspect another part of your code is changing the size of the bar when the food is being clicked. If not, let me know what I don’t understand or post your current code. Thanks :smiley:


maybe because I had:Screenshot_914 that it didn’t work out?

1 Like

With those 2 lines being ran everytime the player clicks it will start from being as large as possible and then tweening down to the correct place (looks like a cooldown). Try it without, and you should be good.

wait is your variable: local amount = 10 my variable local TOTALCLICK = 10?

Mine is just an example!

Just use TOTALCLICK instead. Remove those other 2 lines, and put

main:TweenSize( * 0.9, 0, 0.9, 0), "Out", "Quad", .5, true)

instead of the other tweening line.

it’s a little bit delayed like when you click it it will take like 1 sec but when the number reach 0 the main will be at 0.1 and I want it to end 0 and 0 like the main has a size of 0 and the number is 0

The Y value in your tweensize was 0.8 in the original example. but I used 0.9 in mine by accident. That could be making it look weird.

Anyway, glad I could help! :smiley:

1 Like