Hello! So I want to make a chat command that will open a Gui if the player meets the group requirements and uses the command.
Heres the script:
local GroupId = 11941815
local MinimumRankToUseCommand = 15
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
if Message == “/Commands” and Player:GetRankInGroup(GroupId) >= MinimumRankToUseCommand then
game.StarterGui.NextTechADMIN.VerificationPanel.Enabled = true
end
end)
end)
You can’t change properties of ScreenGuis throught server side script. I recommend first clone your gui to all players and later make it visible for given player.
Something like this:
local GroupId = 11941815
local MinimumRankToUseCommand = 15
local ScreenGui = game.ReplicatedStorage.ScreenGui -- Your screen/object gui
game.Players.PlayerAdded:Connect(function(Player)
local clone = ScreenGui:Clone()
clone.Enabled = false
clone.Parent = Player:WaitForChild("PlayerGui")
Player.Chatted:Connect(function(Message)
if Message == "/Commands" and Player:GetRankInGroup(GroupId) >= MinimumRankToUseCommand then
clone.Enabled = true
end
end)
end)
function PlayerAdded(Player)
Player.Chatted:Connect(function(Message)
if Message:lower() == "!cmds" then
Player:WaitForChild("PlayerGui").ScreenGui.Enabled = true
end
end)
end
for _,v in ipairs(game.Players:GetChildren()) do
coroutine.wrap(PlayerAdded)(v)
end
game.Players.PlayerAdded:Connect(PlayerAdded)
Edit: Weird, it worked when I tried it but now its not.