In a bit of a sticky situation at the moment. This is code to make a Gui appear in screen when a command “/panel” in chatted. As you can see I’ve attempted to debug this myself but had no luck.
The following code is for an admin panel so the group check is only temp. and will be replaced with a remote event to check group rank!
The main problem is that the Gui also has a close button. These scripts work independently and should have no problem doing so. The Gui appears on the players screen the first time after chatting “/panel” but after closing and attempting to reopen the panel the second time, it does not work. No error, No broken or incorrect code. I’m just confused to what the problem is.
Gui Enable Code
game.Players.PlayerAdded:Connect(function(player)
print(player)
player.Chatted:Connect(function(message)
print(message)
if message == "/panel" then
if not player:IsInGroup(8239851) then
print("Not in group")
else
print("In Group")
player.PlayerGui.MacScreen.Enabled = true
end
end
end)
end)
Close Button Code
local Button = script.Parent
Button.MouseButton1Down:Connect(function()
game.Players.LocalPlayer.PlayerGui.MacScreen.Enabled = false
end)
If anyone can point me in the right direction it would be greatly appreciated!
with the close button script youre actually only settings the MacScreens Enabled property to false on your client which the server script cant detect, try firing a remote event that changes the Enabled property on a server script when the close button is pressed
The Chatted event is fired on both the server and client meaning you can open the panel entirely on the client. This is a better solution compared to the server telling the client when to open the panel, through a RemotEvent, because it reduces latency and removes unnecessary complexity.
Local script example:
-- Services
local players = game:GetService("Players")
-- Variables
local player = players.LocalPlayer
-- Open admin panel
player.Chatted:Connect(function(message)
if message == "/panel" then
if player:IsInGroup(8239851) then
player.PlayerGui.MacScreen.Enabled = true
end
end
end)
This is not necessary as the client already requests the server to check if they are in a group when you call IsInGroup. In addition, clients can fully manipulate anything on the client including opening the admin panel meaning you cannot purely rely on just hiding the admin panel. For true security, you should be verifying any requests from a client, such as kicking other players, on the server to assure they have admin permissions.