What do you want to achieve?
I want a button (GUI) to be only visible for members of this group (group ID: 16438390) who haves the ranks 2, 3, 4, 5, and 255.
What is the issue?
I tried a script and it didn’t worked. I placed it into a normal script under a TextButton.
The script should make the GUI to players who don’t have the rank 254, and I have the rank 255. But it doesn’t work. Also I know it only do that for the 254 rank and not for 2, 3, 4, 5, and 255 but I wanted to try. Also I don’t know how to make it for a few ranks, except using a few times the same script. And I see there are things with MouseClick, and I don’t want it to hide only when someone click it. I didn’t made this script, it comes from this topic.
function onMouseClick(player)
local playerUI = player:FindFirstChild("PlayerGui")
if Player:GetRankInGroup(16438390) == 254 then
playerUI.ButtonGui.Frame.Visible = true
else
playerUI.ButtonGui.Frame.Visible = false
end
end
end)
clickdetector.MouseClick:Connect(onMouseClick)
What solutions have you tried so far?
I don’t know at all what I can do.
Thank in advance for your help, have a great day and happy developping!!
local ranks = {2,3,4,5}
clickdetector.MouseClick:Connect(function(player)
local rank = Player:GetRankInGroup(16438390)
local permission = table.find(ranks, rank) or rank >= 254
if permission then
player.PlayerGui.ButtonGui.Frame.Visible = true
else
player.PlayerGui.ButtonGui:Destroy()
end
end)
If the player doesn’t have permission to use the button, it is destroyed. This is so exploiters can’t use it if they make it visible again. If you’re using remote events, it should have the same logic to check for permission.
I think for extra extra safety reasons, you should make the permission system on the server, so that it can really check if you’re allowed to use it or not. Use RemoteFunctions!
local player = game.Players.LocalPlayer
local button = script.Parent
if player:IsInGroup(1) then -- change 1 to your group id
button.Visible = true
else
button.Visible = false
end