Why isnt this working

So i want a gui to pop with a list of all player names for an invite system.

my script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local list = ReplicatedStorage:WaitForChild("PlayerList")
local ScrollingFrame = script.Parent.ScrollingFrame
local Players = game:GetService("Players")

local player1 = game.Players.LocalPlayer

local char = player1.Character or player1.CharacterAdded:Wait()
local cam = workspace.CurrentCamera

repeat wait() until cam.CameraSubject ~= nil
char.Archivable = true
local dummy = char:Clone()
dummy.Parent = workspace

dummy:MoveTo(workspace.LobbySpawns.MainSpawn.Position)

local function PlayerList(player)
	local CloneFrame = list:Clone()
	CloneFrame.TextLabel.Name = player.Name
	CloneFrame.TextLabel.Text = player.Name
	list.Parent = ScrollingFrame
	CloneFrame.Visible = true
	if CloneFrame.TextLabel.Text == player1.Name then
		CloneFrame:Destroy()
	end
end

local function PlayerJoined(player)

	PlayerList(player)

end

for _, players in pairs(Players:GetPlayers()) do

	PlayerList(players)

end

local function PlayerLeft(plr)

	for i, v in pairs(ScrollingFrame:GetChildren()) do

		if v.Name == plr.Name then

			v:Destroy()

		end

	end

end

wait(3)

Players.PlayerAdded:Connect(PlayerJoined)

Players.PlayerRemoving:Connect(PlayerLeft)

it worked when it was cloning a textlabel but when i switched from textlabel to a frame it didnt work anymore.

when i press play i have an error: TextLabel is not a valid member of Frame "PlayerList"

Im not sure in which line you had the error but i think it’s because of this.
list.Parent = ScrollingFrame
You changed the variable “list” Position so its not on ReplicatedStorage anymore.

I changed it but still not working
i have an error on line 21

2 Likes

It works now
i just changed from

local function PlayerList(player)
    local CloneFrame = list:Clone()
	CloneFrame.TextLabel.Name = player.Name
	CloneFrame.TextLabel.Text = player.Name
	list.Parent = ScrollingFrame
	CloneFrame.Visible = true
	if CloneFrame.TextLabel.Text == player1.Name then
		CloneFrame:Destroy()

to

local function PlayerList(player)
	local CloneFrame = list:Clone()
	local TextLabel = CloneFrame.TextLabel
	TextLabel.Name = player.Name
	TextLabel.Text = player.Name
	CloneFrame.Parent = ScrollingFrame
	CloneFrame.Visible = true
	if TextLabel.Text == player1.Name then
		CloneFrame:Destroy()
2 Likes