Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to detect if a bunch of buttons were hovered/pressed?

Asked by 8 years ago

Let's say I do this:

local getall = script.Parent.Characters:GetChildren()

I am trying to detect any of those buttons in that characters frame that have been hovered over or clicked without having to put a script in each one. Is there any way to do that?

1 answer

Log in to vote
0
Answered by 8 years ago

Here's an example. All explaining is done in the script, sorry I can't explain it any better.

for _,v in pairs(script.Parent.Characters:GetChildren()) do -- Gather all them
    if v:IsA("TextButton") then -- You wouldn't want it to mouse over Script's
        v.MouseEnter:connect(function() -- Function
            print(v.Name) -- Print the name, you can edit this.
        end) -- End the function
    end -- End the if statement
end -- End the gathering

If there are any error's please let me know, I didn't test it but I'm pretty sure it'll work.

0
Dis gon' work. Upvoting. DragonODeath 50 — 8y
Ad

Answer this question