Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player isn't showing up on SurfaceGUI?

Asked by 4 years ago

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)
0
Are you getting any errors in your code? MrLonely1221 701 — 4y
0
Nope. I sadly get nothing. DeAuroraxx 50 — 4y
0
Do the players need to interact with this gui in any way or is it just listing the players in the server? MrLonely1221 701 — 4y
0
Yeah, you got a point there Lonely. (; TheWaterFoox 255 — 4y
View all comments (2 more)
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 MrLonely1221 701 — 4y
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 TheWaterFoox 255 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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

1
This is exactly how I did it. MrLonely1221 701 — 4y
0
It's working! Thank you so much :)! DeAuroraxx 50 — 4y
Ad

Answer this question