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

Why doesn't my script work that detects when a certain GUI is clicked?

Asked by 4 years ago

I have a folder with a list of player names and buttons, and I want to detect when and which one is clicked. However, when I attempt to print out the button, nothing seems to happen. Here is my code:

local ScrollingFrame = Players.LocalPlayer:WaitForChild("PlayerGui").Cashier.partyFrame.ScrollingFrame 
local PlayerNames = ScrollingFrame.PlayerNames -- this accesses the folder

for i,v in ipairs(PlayerNames:GetChildren()) do
    v.MouseButton1Click:Connect(function()
        print(v.Name)
    end)
end

Answer this question