Your script does not work because on line 6, you are attempting to check if the player's name is specifically "Admins", and not checking from the table properly. The for loop you have on line 5 is correct.
You are also trying to enable a GUI which is in the StarterGui and not in the person's PlayerGui itself. Doing this from a server script will not work either way, we'll need to use Remote Events to communicate between the Server and Client to make the GUI visible.
You'll need 2 scripts. One local script, and one server script. Put a localscript anywhere within the client, like the StarterGui for example.
Put the server script in ServerScriptService.
Server Script:
The v in for i, v in pairs(Admins) do signifies something inside the table while the i tells you the position the loop is currently at.
local Admins = {"jayfig04"}
local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "GuiPanel"
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
for i, v in pairs(Admins) do
if Player.Name == v then
if message == "/open" then
Event:FireClient(Player)
end
end
end
end)
end)
Local Script:
local Event = game.ReplicatedStorage:WaitForChild("GuiPanel")
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
Event.OnClientEvent:Connect(function()
PlayerGui:FindFirstChild("Panel").Enabled = true
end)
If you have any more questions, or something doesn't work, let me know by replying with a comment. If you are satisfied with the answer, be sure to accept it))
Edits:
There were three issues with the server script i provided. I accidentally added a random hyphen, which errored the script.
The other two issues were something that i didn't see that came from the original script you've provided. You were trying to use gsub without passing a string in the first argument and the other is that you shouldn't use a function value as an argument.
7 comments
connect is deprecated and so is the parent argument to Instance.new
Agreed.
Bad habit, sorry folks. All fixed (:
When i do "/open" I get a error 17:37:13.384 - Stack Begin 17:37:13.386 - Script 'ServerScriptService.SScript', Line 10 17:37:13.388 - Stack End
I'll provide a fix in the next 5 minutes.
Fixed, should work now.
Thank u for the help man!