Hello!
I have this script, which deletes a button and frame inside the GUI if the person is either:
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)
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()