I’m trying to make it so when you click the button, the button move down a little and then back up, like you are actually clicking a button. I know I could just set it’s Y coordinate to go down say 5 pixels, then back up 5 pixels, but that does not seem like the most efficient way and so I’m trying to experiment with different UI animation styles. This just made the UI go to some random place though, dont know why
try using the new TweenService, and I believe the tween style you are after might be back, not bounce. this way you can move it up 5px by decreasing the Y offset, then have it automatically revert back to its original position, as the TweenService has a reverse property.
local TweenService = game:GetService("TweenService")
local yourButton = script.Parent
local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true)
local buttonEffect = TweenService:Create(yourButton, tweenInfo, {Position = UDim2.new(6, 0, 3.02, 0)})
script.Parent.MouseButton1Click:connect(function()
buttonEffect:Play()
end)
I’m basically taking the Button.Position.Y.Scale and increasing it by 0.01 in the tween. Since Reverse is enabled, the tween will reverse and the button will go back to what it was.
Here’s a .rbxl of it for reference, if you hit Play you can test it out for yourself and mess around with tween settings. buttonEffect.rbxl (16.4 KB)
You should probably add a debounce to the button click event