So how do I make a Gui Only certain players can see for like moderators in game.
local moderators = {“Frepzter”,“FrepzterRB”}
—show gui
Please help me i already tried it but its not working
local BronzeTiers = {“Frepzter”,“FrepzterRB”}
while true do
wait()
for i,verify in pairs(BronzeTiers) do
if verify == script.Parent.Parent.Parent.Name then
warn(verify…" is a moderator")
script.Parent.Enabled = true
else
warn(verify…" is not a moderator")
script.Parent.Enabled = false
end
end
end
What you should do is check this on the server and then parent the ScreenGui class to the player’s PlayerGui.
Example:
local ModeratorIds = {1, 2, 3, 4}
game:GetService("Players").PlayerAdded:Connect(function(Player)
if table.find(ModeratorIds, Player.UserId) then
gui_path.gui:Clone().Parent = Player:WaitForChild("PlayerGui")
end
end)
@Wxeeknd works brilliantly however it doesnt reappear when player respawned i tried making a characterAdded Event but still wont work
local ModeratorIds = {288094249}
local plrService = game:GetService(“Players”)
plrService.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(char)
if table.find(ModeratorIds, Player.UserId) then
game.ServerStorage.BronzeMod:Clone().Parent = Player:WaitForChild(“PlayerGui”)
end
end)
end)
Setting “Reset on spawn” to false should do the trick, unless there is some other script interfering.
An alternative is to move the GUI to ReplicatedStorage then make a script in ServerScriptService that goes along the lines of
local gui = game.ReplicatedStorage[""] --fill in quotation marks with name of gui | this defines the pathway
local moderators = {"Frepzter", "FrepzterRB"}
game.Players.PlayerAdded:Connect(function(plr) --connects a function when the playeradded event is fired
if table.find(moderators, plr.Name) then --looks for the player's name in the moderators table
local ui = gui:Clone() --clones the gui
ui.Parent = plr.PlayerGui --parents the gui to the player's playerugi
ui:FindFirstChildWhichIsA("Frame").ResetOnSpawn = false --sets the resetonspawn property to false
end
end)
If you wanted to, you could swap out the string values in the “moderators” table for intvalues, and swap “plr.Name” to “plr.UserId”