Mouse Click Tweening Help

Hi,
I’m currently trying to add an effect when you click an imagebutton which creates an imagelabel and it fades via tweening.
The white ring/clicking effect should have it’s position toward the pointing finger of the hover mouse icon. https://gyazo.com/5588f5a26de1482d7355fc442b618aa3

You can see it’s offsetted toward the right, but it needs to be more toward the left.
I’ve tried basic math to fix the X position to no prevail lol.

And for the size of it, I want it to slowly increase from all directions instead of only downward.
I figure this will require tweening it’s position as well but I’m not sure how to find the appropriate values.

local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local btn = script.Parent
local Frame = btn.Parent

local pressedBtn = Color3.fromRGB(205,177,252)

script.Parent.MouseButton1Down:Connect(function()
	btn.ImageColor3 = pressedBtn
	local x, y = mouse.X, mouse.Y
	
	local sizeFrame = Instance.new("Frame",btn.Parent.Parent)
	sizeFrame.Size = UDim2.new(0.1,0,0.1,0)
	sizeFrame.BackgroundTransparency = 1
	
	local ring = Instance.new("ImageLabel", btn.Parent)
	ring.Size = UDim2.fromScale(.025,0)
	ring.BackgroundTransparency = 1
	ring.ScaleType = 'Fit'
	ring.Image = "rbxassetid://5221791428"
	ring.ImageColor3 = Color3.fromRGB(255,255,255)
	ring.Position = UDim2.new(0,x,0,y)
	
	local goal = {}
	goal.Size = UDim2.fromScale(.025,.05)
	goal.ImageTransparency = 1
	
	local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
	local tween = TweenService:Create(ring, tweenInfo, goal)
	tween:Play()
	tween.Completed:Wait()

	Debris:AddItem(ring,1)
	Debris:AddItem(Frame,1)
end)

Adjust the AnchorPoint. I believe you want the button to scale away from its center? Make it {0.5, 0.5}. You may have to adjust the position of the button after.

1 Like

Oh wow that worked and fixed both of my problems.
Thanks so much

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.