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

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

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

✓ Accepted answer

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??

3 comments

0

The second argument of Instance.new() is deprecated, and you can simply concatenate as such: game.Players[name].PlayerGui

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

0

Thanks so much everyone! You are all awesome!

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