Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make an ImageLabel Go up then down when you click it?

Asked by 3 years ago

I'm making a simulator game where at the start your only way of getting coins is by clicking a button. I am trying to make it so that when you click the button it bounces up then down every click. Does anyone know how?

0
use tweening astonplep 32 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Take A Look At The Roblox DevForum It Should Help You:

https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenSizeAndPosition

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Try this code, Use an ImageButton instead of ImageLabel

local debounce = false
local PosToMove = UDim2.new(0,20,0,20) --Position to move when clicked
local OtherPosTM = UDim2.new(0,50,0,50) --Back to its original position
script.Parent.MouseButton1Click:Connect(function()
If not debounce then
debounce = true
script.Parent:TweenPosition(PosToMove,
Enum.EasingDirection.InOut, --Or other
Enum.EasingStyle.Bounce, --You want bounce isnt it?
1.5, --The duration of the tween
end)
wait(1) --Wait a second before tweening again
script.Parent:TweenPosition(OtherPosTM,
Enum.EasingDirection.InOut, --Or other
Enum.EasingStyle.Bounce, --You want bounce isnt it?
1.5, --The duration of the tween
wait(0.5) --Wait so you can deactivate the debounce
debounce = false
end)

TweenPosition is a function used mostly to animate GUIS, the first parameter is where to move to, the other parameter is the EasingDirection, next, the EasingStyle and the duration.

If you want more information go see page: https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenPosition

Hope it helps!

Answer this question