Hello! This is a base start on a new GUI I am making. I have a UI designer making the UI elements for me, but I am trying to understand how every time a button within a Screen GUI is clicked, it makes a ripple effect come off the mouse.
- I need to have it so that it can check all children at all times, instead of having multiple useless scripts firing remote events etc.
- The ripple effect itself to work,
- To reset and continue to function in a while loop or something along those lines.
Thanks all,
Ripple effects are actually pretty easy
- There’s usually a circular image / hollow circle
- Whenever the UI Object is clicked , you get the current mouse position
- Then you simply clone the circular image and set it’s position to the mouse location
- Lastly you create a tween which increases the size of the image , and changes it’s transparency to 1
Thanks. The primary issue I face is the constant running of the script, There are going to be multiple buttons that the script should constantly check. How can I easily get a list using the :IsA function and then contantly check if those specific parts are clicked. Note it cannot be pre-identified as the script itself duplicates a UIGridLayout depending on a pre set table, which is already scripted (not a part of the question I am asking.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Frame = -- Frame object here which holds all of your buttons
local function ripple(button)
-- Do the ripple on the button here
local Mouse = Player:GetMouse()
local x, y = Mouse.X, Mouse.Y
-- Now you have the coordinates, clone your circle ripple
-- and then position it (with offset) to the coordinates
-- then simply make a for loop (for transparency) and tween it
end
for _, button in pairs(Frame:GetChildren()) do
if not button:IsA("TextButton") then -- or whatever type of button
return
end
button.MouseButton1Down:Connect(function()
ripple(button)
end)
end
3 Likes
Thank you for replying and, of course, Happy Birthday!
I have tried this and it does work with some tweaks I made for testing purposes. However, I am struggling with how to get all of the descendants. So:
It returns everything there, but when I implement :IsA functionality it does not work as it of course, is not a TextButton. Any help as to a bypass to this would be great
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local descendants = script.Parent:GetDescendants()
local Frame = script.Parent-- Frame object here which holds all of your buttons
local function ripple(button)
-- Do the ripple on the button here
local Mouse = Player:GetMouse()
local x, y = Mouse.X, Mouse.Y
print(x)
print(y)
end
for index, descendant in pairs(descendants) do
print(descendant.Name)
end
What exactly are you trying to do? What do you need the descendants of? What are you trying to click in order to have a ripple effect?
With a few tweaks I got it working. Thank you. I just needed to change it around a bit so that it did not stop the descendant process for frames / imagelabels.