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

How can I get this gui to display to all clients?

Asked by 4 years ago
Edited 4 years ago

Basically, I have a text button that players can click to make a new team with their name on it. Then I want a gui to display that has a textbutton with the teams name that all clients can see. The script makes the team, but the gui doesn't display. I am not getting any errors, but the gui won't display. I am admittedly horrible with guis. Any help would be greatly appreciated.

local RS = game:GetService("ReplicatedStorage")
local Teamevent = RS:FindFirstChild("Teams")

Teamevent.OnServerEvent:Connect(function(player)
    local team = Instance.new("Team")
    team.Name = player.Name
    team.Parent = game.Teams
        for i,v in pairs (game.Players:GetChildren()) do
            local plr = v
            local name = v.Name
            local teamgui = Instance.new("ScreenGui", game.Players.name.PlayerGui)
            teamgui.Enabled = true
            local frame = Instance.new("Frame")
            frame.Parent = teamgui
            frame.Size = UDim2.new(0.5, 0, .5, 0)
            frame.Position = UDim2.new(.25,0,.25,0)
            frame.Visible = true
            local ui = Instance.new("UIListLayout")
            ui.Parent = frame
            local textButton = RS:FindFirstChild("Sample")
            textButton.Parent = frame
            textButton.Text = team.Name
        end
    end)

1 answer

Log in to vote
0
Answered by 4 years ago

I'm not great at scripting but line 11?

local teamgui = Instance.new("ScreenGui", game:GetService("players"):FindFirstChild(name).PlayerGui)

You were just getting game.players.name before which will return "players" (the name of the service, not your variable)

Hopefully this helps??

0
The second argument of Instance.new() is deprecated, and you can simply concatenate as such: game.Players[name].PlayerGui Ziffixture 6913 — 4y
0
Not deprecated. Just note its performance implication if you choose to do that: https://devforum.roblox.com/t/psa-dont-use-instance-new-with-parent-argument/30296/48 xPolarium 1388 — 4y
0
Thanks so much everyone! You are all awesome! Dorchsaoil 11 — 4y
Ad

Answer this question