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

How to make gui only visible for certain players?

Asked by 5 years ago

So when a player joins it should see if his name is in admin list then then gui should be visible for them.... Server Script(below)

local admins = {"dogovpain","Robin9370","meghrajiscool"}

game.Players.PlayerAdded:Connect(function(plr)
    for i = 1,#admins do
        if plr.Name == i then
            game.ReplicatedStorage.Events.TeamChange:FireAllClients()
        end
    end         
end)

Local Script

local event = game.ReplicatedStorage.Events.TeamChange

event.OnClientEvent:Connect(function()
                game.Players.LocalPlayer.PlayerGui:WaitForChild("SpawnTeam").AdminButton.Visible = true
end)

Not that good with Fireclient

1 answer

Log in to vote
2
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

:FireAllClients() fires to all clients. Try this:

local admins = {"dogovpain","Robin9370","meghrajiscool"}

game.Players.PlayerAdded:Connect(function(plr)
    for i = 1,#admins do
        if plr.Name == admins[i] then
            game.ReplicatedStorage.Events.TeamChange:FireClient(plr)
        end
    end         
end)
0
Ty WillBe_Stoped 71 — 5y
Ad

Answer this question