Need Help With Rainbow SHR Nametag!

Hello! I want to make this script only work for people above a certain rank. I have no idea how to do this, can anyone help me?

local character = script.Parent.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)

local N = script.Parent["Player Name"]

	while true do
		for i = 0, 1, 0.01 do
			N.TextColor3 = Color3.fromHSV(i,1,1)
			wait(0.09)
		end
end

I tried to do this earlier but I couldn’t get it to work :confused:

Use Player:GetRankInGroup
check if plr is above a certain rank.

1 Like

You could get the Player’s Rank using Player:GetRankInGroup:

local character = script.Parent.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)

local N = script.Parent["Player Name"]
if player:GetRankInGroup(YourGroupIDHere) >= 200 then 
	while true do
	    for i = 0, 1, 0.01 do
		    N.TextColor3 = Color3.fromHSV(i,1,1)
			wait(0.09)
		end
    end
end

You should also implement a check to make sure that what you’re searching for is a valid player as well

3 Likes

its showing as an error.

local character = script.Parent.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)

local N = script.Parent["Player Name"]

if player:GetRankInGroup(6741421) >= 200 then 
	while true do
		for i = 0, 1, 0.01 do
			N.TextColor3 = Color3.fromHSV(i,1,1)
			wait(0.09)
		end
	end
end

Error:

19:31:47.550 ServerScriptService.NameTagScript.Tag.RB:5: attempt to index nil with ‘GetRankInGroup’. Also does >= mean if above 200 then or if under 200 then?

Your player variable is defined the wrong way, double check that what you’re parenting is correct:

wait()
local character = script.Parent.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)

print(player)
local N = script.Parent["Player Name"]

if player then
    if player:GetRankInGroup(6741421) >= 200 then 
	    while true do
		    for i = 0, 1, 0.01 do
			    N.TextColor3 = Color3.fromHSV(i,1,1)
			    wait(0.09)
		    end
	    end
    end
end

That’s just a greater than symbol, it detects if the current rank returned back is greater than 200 or not

1 Like

The player printed “nil”. I don’t think thats a good thing. I think it works actually i tested it on a test account.

Chances are there’s not a valid player/Character that you defined then

It’s supposedly in this line here:

Where is the character Model exactly when this script is called?

Nevermind this time it printed NotAid_n. (My username)

Have you tried using game.Players.PlayerAdded:Connect(function(plr) )

My problem was already solved, the script works perfectly!