Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you remove something based off a rank?

Asked by 8 years ago

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)
1
Please post the error. BinaryResolved 215 — 8y
0
Added. EricDasCaveman69 20 — 8y

1 answer

Log in to vote
1
Answered by
4Bros 550 Moderation Voter
8 years ago

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()


Ad

Answer this question