Hi guys, I am trying to make a ripple effect when I click a button, although it won’t work. Here is my code:
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local Player = Players.LocalPlayer
local button = script.Parent
button.MouseButton1Down:Connect(function()
local Mouse = Player:GetMouse()
local x, y = Mouse.X, Mouse.Y
local circle = game:GetService("ReplicatedFirst").Circle:Clone()
circle.Parent = button
button.BackgroundTransparency = 0
circle:TweenPosition(UDim2.new(x,y))
end)
Here is what that code does:
If you know how to fix this, please leave a reply below. Thanks!
So how would I change circle:TweenPosition(UDim2.new(0,x,0,y)) to use the code he used? (local RelativePosition = Vector2.new(Mouse.X,Mouse.Y)-Button.AbsolutePosition)
First of all don’t use scale but this time offset beacuse mouse is returning you position in offsets.
Then declare variables x and y ,and then use RunService to do the rest.
And i would recommend you checking if the circle isn’t nil.
And yes you should also use RunService for “tweening”