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