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

How do I make it so a GUI shows up for certain players?

Alright, so I want to figure out how to make a GUI show up for certain players. Here's what I tried. What do I need to do?

Here's my script

game.Players.PlayerAdded:Connect(function(plr)
	for i, v in pairs(allowed) do
		if plr.Name == v then
			game.StarterGui.UTG.Enabled = true
		end
	end
end)

Also, this is in a script that's in ServerScriptService. (Not localscript.)

2 answers

✓ Accepted answer

To realse this you need three points. SeverScript, ClientScript, RemoteEvent

Put a RemoteEvent on ReplicatedStorage. Your Script ServerScript:

game.Players.PlayerAdded:Connect(function(plr)
	for i, v in pairs(allowed) do
		if plr.Name == v then
			game.ReplicatedStorage.RemoteEvent:FireClient(plr)
		end
	end
end)

Put a LocalScript ClientScript on StarterGui and write this

local PlayerService = game:GetService('Players')
local Player = PlayerService.LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	PlayerGui.UTG.Enabled = true
end)

2 comments

0

wowow epic thanks for teaching me client-event

0

I thought I didn't have to use a remote event, so I just removed it, but I was wrong before.

StarterGui is for GUIs that are given to the player instantly. You need to change the PlayerGui of that player.

Here is your script fixed:


game.Players.PlayerAdded:Connect(function(plr)
	    for i, v in pairs(allowed) do
               if plr.Name == v then
                    plr.PlayerGui.UTG.Enabled = true
              end
         end
end)


2 comments

0

this doesn't work for me

0

Not FilteringEnabled solution.

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