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)

3 comments
The second argument of Instance.new() is deprecated, and you can simply concatenate as such: game.Players[name].PlayerGui
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
Thanks so much everyone! You are all awesome!