Issue With Admin Panel I am Making

Hey there,

So I am probably doing something dumb here, but it seems the “MouseButton1Click” events are not firing. This is a localscript.

wait(3)

local plr = game.Players.LocalPlayer

local ScreenGui = script.Parent.Parent
local Frame = script.Parent.Parent.Main
local TitleLabel = Frame.Title
local PlayerListFrame = Frame.PlayerList
local FeaturesListFrame = Frame.FeaturesList

local RanksFolder = ScreenGui.Ranks
local DeveloperFolder = RanksFolder.Developer
local AdminFolder = RanksFolder.Admin

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local EventsFolder = ReplicatedStorage.StaffPanelEvents
local ActionEvent = EventsFolder.AdminActions

local SelectedPlayer = nil

local function UpdatePlayerList()
	for i,v in pairs(Players:GetPlayers()) do
		local label = PlayerListFrame.Template:Clone()
		label.Name = v.Name
		label.Visible = true
		label.Text = v.Name
		label.Parent = PlayerListFrame
	end
end

local function ClearLabelsInPlayerList()
	for i,v in pairs(PlayerListFrame:GetChildren()) do
		if v:IsA("TextButton") then
			if v.Name == "Template" then
			else
				v:Destroy()
			end
		end
	end
end

for i,v in pairs(PlayerListFrame:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()			
			print("Clicked"..v.Name)
			
			SelectedPlayer = v.Name
			
			PlayerListFrame.Visible = false
			FeaturesListFrame.Visible = true
		end)
	end
end

for i,v in pairs(FeaturesListFrame:GetChildren()) do
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			if SelectedPlayer == nil then
				PlayerListFrame.Visible = true
				FeaturesListFrame.Visible = false
				
				warn("The player is equal to nil.")
			else
				ActionEvent:FireServer(v.Name,SelectedPlayer)
				
				SelectedPlayer = nil
				
				PlayerListFrame.Visible = true
				FeaturesListFrame.Visible = false
			end
		end)
	end
end

while wait(1) do
	ClearLabelsInPlayerList()
	UpdatePlayerList()
end

Let me know if you have any ideas!
Thank you,

Try using v.Activated instead of MouseButton1Click. If it still doesn’t work, try MouseButton1Down.

You are destroying and creating new buttons AFTER you setup the click events. Try adding the

         label.MouseButton1Click:Connect(function()			
			print("Clicked"..v.Name)
			
			SelectedPlayer = v.Name
			
			PlayerListFrame.Visible = false
			FeaturesListFrame.Visible = true
		end)

code inside UpdatePlayerList