Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do you remove something based off a rank?

Hello!

I have this script, which deletes a button and frame inside the GUI if the person is either:

  1. Not high enough rank OR
  2. Is a high enough rank, but does not have permission to click on the button.

I want this to work so that when a player resets, it still works and this is why I've put this script inside StarterPark.

plr = script.Parent.Parent.Name
local b = plr:GetRankInGroup(1096916)
	if b == 200 then
		script.Handbook.Frame.Menu.DTProc:Destroy()
		script.Handbook.Frame.DTTrainProc:Destroy()
	end
	
	if plr.GetRankInGroup(1096916) < 150 then
		script.Handbook.Frame.Menu.DTProc:Destroy()
		script.Handbook.Frame.DTTrainProc:Destroy()
	end
	


local a = script.Handbook:Clone()
a.Parent = script.Parent.Parent.PlayerGui

script:Destroy()

However, when this does run I get some sort of nil value error. Anyone know what's this about?

EDIT: The error is:

01:36:01.711 - Players.Player.Backpack.Script:4: attempt to call method 'GetRankInGroup' (a nil value)

2 comments

1

Please post the error.

0

Added.

1 answer

✓ Accepted answer

The reason why the method errored is that because you indexed plr as a string, not the player itself. You can't perform that method on a string.

local plr = script.Parent.Parent

as opposed to

local plr = script.Parent.Parent.Name

local plr = script.Parent.Parent
local b = plr:GetRankInGroup(1096916)

if b == 200 then
        script.Handbook.Frame.Menu.DTProc:Destroy()
        script.Handbook.Frame.DTTrainProc:Destroy()
end
 if  b < 150 then -- You dont need to use the method again
        script.Handbook.Frame.Menu.DTProc:Destroy()
        script.Handbook.Frame.DTTrainProc:Destroy()
    end

local a = script.Handbook:Clone()
a.Parent = script.Parent.Parent.PlayerGui
 
script:Destroy()


This discussion is preserved as it was. New answers, comments, and votes are closed.