How to do this shake effect? on ui

Hi, i am doing a music voter system, and currently i want to make something like this

shaketext1

i already got the bpm detector, but how could i make a text or image label shake like that?, and set a intensity

You would probably have to connect RenderStepped to a function which tweens the position based on math.sin()


timeElapsed = timeElapsed + dt

local targetXOffset = amplitude * math.sin(timeElapsed * frequency * 2 * math.pi)
local targetPosition = UDim2.new(originalPosition.X.Scale, originalPosition.X.Offset + targetXOffset, originalPosition.Y.Scale, originalPosition.Y.Offset)

frame.Position = frame.Position:Lerp(targetPosition, lerpSpeed)
2 Likes

Hi!, osorry for the long wait, what numbers do you recommend on lerpSpeed, frequency and amplitude?

Also, originalPosition would be like

local originalPosition = frame.Position

?