Basically, I have this GUI that opens when you use a command. When you press the close button, it works fine. But when you try opening it again, it doesn’t work.
Code:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg == openCommand then
if plr:GetRankInGroup(groupID) >= minRank then
plr.PlayerGui.adminPanel.Enabled = true
end
end
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
local adminPanel = plr.PlayerGui.adminPanel
plr.Chatted:Connect(function(msg)
if msg == openCommand then
if plr:GetRankInGroup(groupID) >= minRank then
if not adminPanel.Enabled then
adminPanel.Enabled = true
end
end
end
if msg:lower() == "close" then
if plr:GetRankInGroup(groupID) >= minRank then
adminPanel.Enabled = not adminPanel.Enabled
end
end
end)
end)
The problem is that you’re opening it on a server script and closing it on a local script. To keep a good practice, ALL gui handling should be handled on local scripts as much as possible.
I will just try firing the client on a remote event, I’ll see if that works. Since the other guy said it messes things up if one is on the server and one is on the local.
local player = game.Players.LocalPlayer
local closeBtn = script.Parent
local openCommand = "CHANGE ME"
local groupID = 1234567890 --change to group id
local minRank = 123 --change to min rank
player.Chatted:Connect(function(msg)
if msg == openCommand then
if plr:GetRankInGroup(groupID) >= minRank then
player.PlayerGui.adminPanel.Enabled = true
end
end
end)
closeBtn.MouseButton1Click:Connect(function()
player.PlayerGui.adminPanel.Enabled = false
end)