Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

1 comment

0

Dis gon' work. Upvoting.

This discussion is preserved as it was. New answers, comments, and votes are closed.