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

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

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?

1 comment

0

use tweening

2 answers

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!

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