#so when player joins its supposed to add a new TextButton

18 messages · Page 1 of 1 (latest)

young beacon
#

but when i test it doesnt do it for me in game but in Studio its creating the TextButtons

local Players = game.Players
local Tags = require(game.ReplicatedStorage.Tags)
function newPlayerAdded( frame)
    for i,v in pairs(Players:GetPlayers()) do
        local TextLabel = Instance.new('TextButton', frame)
        TextLabel.Name = v.Name
        TextLabel.Size = UDim2.new(1,0, 0, 50)
        TextLabel.BackgroundColor = BrickColor.new(0, 170, 127)
        TextLabel.BackgroundTransparency = 0.5
        TextLabel.TextScaled = true
        TextLabel.Font = Enum.Font.FredokaOne
        local newTags = Tags.new(v)
        TextLabel.Text = newTags:CreateTag()

        local uiCorner = Instance.new('UICorner', TextLabel)
        uiCorner.CornerRadius = UDim.new(0, 12)
    end
end
function playerLeft(player, Frame)
    local textLabel = Frame:FindFirstChild(player.Name)
    if Frame.Visible and textLabel then
        if textLabel then
            textLabel:Destroy()
        end
    elseif not Frame.Visible then
        textLabel:Destroy()
    end
end
Players.PlayerAdded:Connect(function(plr)
    local playerGui = plr:WaitForChild('PlayerGui')
    local playerLeft = playerGui:WaitForChild('PlayerList')
    local frame = playerLeft:WaitForChild('playerlist')
    local Stat = playerLeft:FindFirstChild('Stats'):FindFirstChild('PlayerStats')
    newPlayerAdded(frame)
end)
Players.PlayerRemoving:Connect(function(plr)
    local frame = plr:WaitForChild('PlayerGui')
    local playerLeft = frame:WaitForChild('PlayerList')
    local frame = playerLeft:WaitForChild('playerlist')

    playerLeft(plr, frame)
end)```
#

in game for me

#

while the other is just not creating the textbutton

pulsar summit
#

its because youre using playerAdded event
its not firing for anybody who was there before you joined

young beacon
#

so what should i do then

pulsar summit
#
  1. do it n a Local script inside of the GUI
  2. just loop trough every player at the start when
#
for _,plr in Players:GetChildren() do
    addGUI(plr)
end
young beacon
#

its still not adding on the list```lua
local players = game.Players
local Tags = require(game.ReplicatedStorage.Tags)
function createText(player,frame)
local TextLabel = Instance.new('TextLabel', frame)
TextLabel.Name = player.Name
TextLabel.Size = UDim2.new(1,0, 0, 50)
TextLabel.BackgroundColor = BrickColor.new(0, 170, 127)
TextLabel.BackgroundTransparency = 0.5
TextLabel.TextScaled = true
TextLabel.Font = Enum.Font.FredokaOne
local newTags = Tags.new(player)
TextLabel.Text = newTags:CreateTag()

local uiCorner = Instance.new('UICorner', TextLabel)
uiCorner.CornerRadius = UDim.new(0, 12)

end

for i,v in pairs(players:GetPlayers()) do
local Playerlist = script.Parent.PlayerList.playerlist
createText(v,Playerlist)
end```

#

its in the local script

pulsar summit
#

just add the event to it
like


local Playerlist = script.Parent.PlayerList.playerlist

for _,plr in Players:GetChildren() do
    createText(plr,Playerlist)
end


Players.PlayerAdded:Connect(function(plr)
    createText(plr,Playerlist)
end)
young beacon
#

well thats new it used to be Server on the side but now it works

#

ok good now it works

pulsar summit
#

maybe still add

Players.PlayerAdded:Connect(function(plr)
    if plr ~= Player.LocalPlayer then createText(plr,Playerlist) end
end)
young beacon
#

well thats the older one compaired the the bottome one

#

this is after my main leaves but its still adding a new textbutton

#
local players = game.Players
local Tags = require(game.ReplicatedStorage.Tags)
function createText(player,frame)
    local TextLabel = Instance.new('TextLabel', frame)
    TextLabel.Name = player.Name
    TextLabel.Size = UDim2.new(1,0, 0, 50)
    TextLabel.BackgroundColor = BrickColor.new(0, 170, 127)
    TextLabel.BackgroundTransparency = 0.5
    TextLabel.TextScaled = true
    TextLabel.Font = Enum.Font.FredokaOne
    local newTags = Tags.new(player)
    TextLabel.Text = newTags:CreateTag()

    local uiCorner = Instance.new('UICorner', TextLabel)
    uiCorner.CornerRadius = UDim.new(0, 12)
end
function destroy(frame)
    for i,v in pairs(frame) do
        if v:IsA('TextLabel') then
            v:Destroy()
        else
            return false
        end
    end
end
for i,v in pairs(players:GetPlayers()) do
    local Playerlist = script.Parent.playerlist
    createText(v,Playerlist)
end
players.PlayerAdded:Connect(function(plr)
    createText(plr,script.Parent.playerlist)
end)
players.PlayerRemoving:Connect(function(plr)
    destroy(script.Parent.playerlist:GetChildren())
end)```
pulsar summit
#
local Playerlist = script.Parent.playerlist

for i,v in players:GetPlayers() do
    createText(v,Playerlist)
end


players.PlayerAdded:Connect(function(plr)
    createText(plr,Playerlist)
end)


players.PlayerRemoving:Connect(function(plr)
    local ui = Playerlist:FindFirstChild(plr.Name)
    if ui then ui:Destroy() end
end)