Script not working properly

Hello.

So here’s the issue.

When I join the game on my main account, It shows my profile. When I join on my alt account, It just duplicates it and says, Player1. (Which is the text’s GUI.)

But for that alt account it shows my name and their name.

game.Players.PlayerAdded:Connect(function(player)

local Plr = player

local Temp = script.Template:Clone()
Temp.Parent = script.Parent.Parent.ScrollingFrame
Temp.Name = Plr
print("Done. (1/2)")

Temp.PlayerName.Value = Plr
Temp.Plr_Image.LocalScript.Disabled = false
print("Done. (2/2)")

end)



local PLAYERS = game.Players:GetChildren()
for i = 1, #PLAYERS do
	local Plr = PLAYERS[i].Name

local Temp = script.Template:Clone()
Temp.Parent = script.Parent.Parent.ScrollingFrame
Temp.Name = Plr
print("Done. (1/2)")

Temp.PlayerName.Value = Plr
Temp.Plr_Image.LocalScript.Disabled = false
print("Done. (2/2)")

end

Thanks!

Don’t set the name to the ‘Player’, either to do,

Temp.Name = tostring(player)

or

Temp.Name = player.Name

That didn’t fix anything on the script. Its still doing the same thing. Lemme send some ss

This is AboutGolden’s perspective when he joins second.

Yeah, that would be more helpful. Kind of hard to understand your issue based on the explanation.

This is TheBigC10’s Perspective when he joins first.

Would changing that to this help?

local PLAYERS = game.Players:GetPlayers()

That will help instead of doing GetChildren(). But im still having the issue. : p

Why cant you just do a client event, and :FireAllClients it would be much easier. It would look something like this

local player = game.Players.LocalPlayer
ClientEvent.OnClientEvent:Connect(function()
    local Template = script.Template:Clone()
    Template.NameDisplay = player.Name
    Template.AvatarDisplay = player:GetUserThumbnailAsync(player.UserId,Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
    Template.Parent = ScrollingFrame
end)

--Server

game.Players.PlayerAdded:Connect(function(player)
   ClientEvent:FireAllClients(player)
end)

Does it print Done 1/2 and Done 2/2 for the 2nd player that joins or no?

Actually, try adding a wait(1) or wait(2) before it iterates through everyone in game.

It does print both! Must be a weird error.

Ill try this! Thank you! (30 Letters!!)

Does it print once or twice? Also, it might not work due to both players not being fully loaded in yet so only one player has his/her thing loaded in.

Ooh, Ill try to add a wait() line.

Its saying this when I join after AboutGolden.

What’s line 3? (30 letterssssssssss)

print(player.." Is Joining")

That’s line 3.

Should I do something like, player.Name?

1 Like

Try using player.Name instead of just player