I have made a script where you can click on other players and then a function fires. I'm still new to scripting so there might be a way to do this that I just haven't learned yet.
In my game, I have already inserted a ClickDetector on every players Character. I made a Local Script in StarterGui that reacts to when you click on the player. However, I'm not sure how to get it to click on an array of objects. I tried using this script to fix the problem:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Human = game.Workspace:GetChildren()
if Human.ClickDetector ~= nil then
Human.ClickDetector.MouseClick:connect(function(player)
print "clicked on a player"
end)
end
However, this doesn't make the ClickDetector respond. The function works when I make a specific name for the variable, but not when the variable is an array of objects. How can I get this to work when clicked on any player with a ClickDetector in their character?

3 comments
Thanks, but is there any way to connect this to a LocalScript? Because I have a GUI pop up when the players are clicked, that's why I was using a LocalScript
Make a RemoteEvent and use FireClient
Thank you!