Unable to cast Instance to int64 using UserHasBadgeAsync

I am trying to make an chat tag for those that own a special badge, however, i am getting this error:

15:00:38.474 Unable to cast Instance to int64 - Client - Tags:16
15:00:38.474 Stack Begin - Studio
15:00:38.475 Script ‘Players.Komas19.PlayerScripts.Tags’, Line 16 - Studio - Tags:16
15:00:38.475 Stack End - Studio
15:00:38.475 Error occurred while calling TextChatService.OnIncomingMessage: Error occurred while calling TextChatService.OnIncomingMessage: Unable to cast Instance to int64 - Client

What im thinking, is that its due to the new format for badge ids

code:

local ChatService = game:GetService("TextChatService")
local Players = game:GetService("Players")

local Owner = {2612956684} -- Change this to your userid.
local Dev = {835873273} -- Change this to your userid.

ChatService.OnIncomingMessage = function(message: TextChatMessage)
	local props = Instance.new("TextChatMessageProperties")

	if message.TextSource then
		local playerid = Players:GetPlayerByUserId(message.TextSource.UserId)
		props.PrefixText = "<font color='#6a8e04'>[Player]</font> " .. message.PrefixText
		
	    local badge = 1232881659795991
		
		if game:GetService("BadgeService"):UserHasBadgeAsync(playerid, badge) == true then
			local r = math.random(0, 255)
			local g = math.random(0, 255)
			local b = math.random(0, 255)
			
			local hex = Color3.fromRGB(r, g, b):ToHex()
			
			props.PrefixText = "<font color='"..hex.."'>[???]</font> " .. message.PrefixText
		end

		for _, v in pairs(Owner) do
			if Players[tostring(playerid)].UserId == v then
				props.PrefixText = "<font color='#5D3FD3'>[Owner]</font> " .. message.PrefixText
			end
		end
		for _, v in pairs(Dev) do
			if Players[tostring(playerid)].UserId == v then
				props.PrefixText = "<font color='#0000FF'>[Dev]</font> " .. message.PrefixText
			end
		end
	end

	return props	
end

The new badge id is an randomly generated integer that is quite long, maybe BadgeService has an issue with it?

Nevermind, i had to do this server-side

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.