I want to make the “Handles” in my game visible and invisible depending on your rank in the roblox group. This should be player sided and the localscript doesn’t change the visibility for all players that join.
The current localscript I tried so far does not work whatsoever, I pasted it under the handles itself, which I plan to put in ReplicatedStorage, which I’m not allowed to change. Also another issue I’m facing is that despite the “Handles” being in ReplicatedStorage, they are still somehow visible upon joining.
I’ve already tried searching for solutions on the forum, and asking ChatGPT to try and make changes to fix it, but no effect was made.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local player = game.Players.LocalPlayer
local groupid = 14664007
local minrank = 244
if player:GetRankInGroup(groupid) >= minrank then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
Print player:GetRankInGroup(groupid) and see what’s returned. I also recommend you make a server script, check for the player’s group rank, and then copy the “Handle” to the player’s PlayerGui instead. This will prevent exploiters from getting ahold of this “Handle.”
A “handle” isnt something that can be used to modify anything ingame, it’s just a visual indicator, so it doesn’t really need to be protected from exploiters.
What should I add to the serverscript to fix the main issue, though?
local player = game.Players.LocalPlayer
local groupid = 14664007
local minrank = 244
print(player:GetRankInGroup(groupid)
if player:GetRankInGroup(groupid) >= minrank then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
Perhaps using the GroupService would be more reliable for this?
local GroupService = game:GetService("GroupService")
local PlayerIsInGroup = function()
local Success, Groups = pcall(GroupService.GetGroupsAsync, GroupService, Player.UserId)
if not Success or #Groups == 0 then
return false, 0
end
local IsInGroup = false
local GroupRank = 0
for _, Group in ipairs(Groups) do
if Group.Id == GROUP_ID then
IsInGroup = true
GroupRank = Group.Rank
break
end
end
return IsInGroup
end
...
local IsInGroup, GroupRank = PlayerIsInGroup()
if IsInGroup and GroupRank >= MINIMUM_RANK then
Frame.Visible = true
else
Frame.Visible = false
end
The output will give you errors and display printed info during runtime. Using it is very useful for debugging. To open it, go from the Topbar → Script → Output. A bar that says “Output” will then be opened.
Honestly, I would just recommend you learning the basics of scripting first, with tutorials from people such as TheDevKing, so that you could be able to fix some of these rather simple problems on your own.
Some advice: Don’t try programming if you can’t do something as simple as printing a number.
Watch a lot of tutorials before attempting anything with programming.
Here’s things for you to consider:
Is the script enabled?
Is the script even running? (If not, put it under StarterCharacterScripts)
Is the script type correct? Your code requires a LocalScript