Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player isn't showing up on SurfaceGUI?

Hey. I'm currently working on a PlayerList with all the names of all players in the game. I want to display them on a part but something isn't working. It works fine with a ScreenGUI but I must display it on a SurfaceGUI and that's the problem. It's not showing up on the SurfaceGUI and I don't know why.

local BoardList = game:GetService("ReplicatedStorage"):WaitForChild("BoardList")
local holder = script.Parent:WaitForChild("holder")

local function add(player)
		local new = BoardList:Clone()
	new.name.Text = player.Name
	if not new.name.TextFits then
		new.name.TextScaled = true
	end
	new.Position = UDim2.new(0, 190, 0 + (.103 * #holder:GetChildren()), 0)
	new.Parent = holder
end

add(game.Players.LocalPlayer)

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

6 comments

0

Are you getting any errors in your code?

0

Nope. I sadly get nothing.

0

Do the players need to interact with this gui in any way or is it just listing the players in the server?

0

Yeah, you got a point there Lonely. (;

0

Don't know why you deleted your answer, it was still good code. I was just saying another way to do it if he doesn't need users to click on players

0

It wasn't what he was looking for, so I thought It would be better if I left it out to not confuse anybody

1 answer

✓ Accepted answer

Alright. I tested out your code, and it seems to be working good.

Although, I did remove the repositioning line since it did not really work. In exchange I placed an UIListLayout inside the SurfaceGui to make prevent the GuiObjects from overlapping. You can see how i did it inside this place: (It is uncopylocked) https://www.roblox.com/games/4709982824/Scriptinghelpers

I did also remove the add(game.Players.LocalPlayer) since the script is a serverscript and can't call a localPlayer.

local BoardList = game:GetService("ReplicatedStorage"):WaitForChild("BoardList")
local holder = script.Parent:WaitForChild("holder")

local function add(player)
    local new = BoardList:Clone()
    new.name.Text = player.Name
    if not new.name.TextFits then
        new.name.TextScaled = true
    end
    new.Parent = holder
end


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

And that's about it. Feel free to comment if there was something I didn't answer correctly or you have more question.

Happy scripting!


~Sethex

2 comments

1

This is exactly how I did it.

0

It's working! Thank you so much :)!

This discussion is preserved as it was. New answers, comments, and votes are closed.