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

Getting error "attempt to call method 'GetRankInGroup' (a nil value)?

I'm working on chat tags, and got them working pretty well with badges. It would display everything correctly, but as soon as I start working with GetRankInGroup it starts bugging out. I've looked online a lot to find the issue but cant. Here's the script.

local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")

ChatService.SpeakerAdded:Connect(function(player)
	local Speaker = ChatService:GetSpeaker(player)
	if player:GetRankInGroup(5196996) == 254 then
		Speaker:SetExtraData('Tags', 
			{{TagText = "Owner",
			 TagColor = Color3.fromRGB(255, 0, 0)
			}})
	elseif BadgeService:UserHasBadgeAsync(Players[player].UserId, 1397218698) then
		Speaker:SetExtraData('Tags', 
			{{TagText = "Alpha",
			 TagColor = Color3.fromRGB(239, 184, 56)
			}})
	end
end)

The error message seems to take me to line 09. Not sure whats up with that, but it worked fine before having the Owner rank.

1 answer

Hello, yes i've checked your script twice and it's beacuse somehow it can't define the users, i've fixed it tho here ya go:

local ServerScriptService = game:GetService("ServerScriptService")
local ChatService = require(ServerScriptService:WaitForChild("ChatServiceRunner"):WaitForChild("ChatService"))
local Players = game:GetService("Players")
local BadgeService = game:GetService("BadgeService")

ChatService.SpeakerAdded:Connect(function(player)
    local Speaker = ChatService:GetSpeaker(player)
    if Players[player]:GetRankInGroup(5196996) == 254 then
        Speaker:SetExtraData('Tags', 
            {{TagText = "Owner",
             TagColor = Color3.fromRGB(255, 0, 0)
            }})
    elseif BadgeService:UserHasBadgeAsync(Players[player].UserId, 1397218698) then
        Speaker:SetExtraData('Tags', 
            {{TagText = "Alpha",
             TagColor = Color3.fromRGB(239, 184, 56)
            }})
    end
end)

if it worked please accept, thank you

2 comments

0

That did it. Unknown how to accept however. Let me know and I will.

0

uh click on the button that says "accept sulation" or something that has accept in it.

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