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

How to make gui only visible for certain players?

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

✓ Accepted answer

: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)

1 comment

0

Ty

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