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

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

Asked by
Loot_O 42
4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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)
0
wowow epic thanks for teaching me client-event Frometa1998 35 — 4y
0
I thought I didn't have to use a remote event, so I just removed it, but I was wrong before. Loot_O 42 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)
0
this doesn't work for me Loot_O 42 — 4y
0
Not FilteringEnabled solution. NiniBlackJackQc 1562 — 4y

Answer this question