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

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by
VitroxVox 884 Moderation Voter
4 years ago

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

0
That did it. Unknown how to accept however. Let me know and I will. YourBoiKdude 2 — 4y
0
uh click on the button that says "accept sulation" or something that has accept in it. VitroxVox 884 — 4y
Ad

Answer this question