I have recently been trying to make a system where if the player in the game has a value greater than mine, they will be rewarded with a badge. However, when trying to compare my data from the datastore to the player’s current value, It comes up with an error, saying “Unable to cast instance to int64”
I have printed my data out in the output, and it reads as “104”, however, it still won’t compare the two numbers.
Here is the code:
local DataStoreService = game:GetService("DataStoreService")
local BadgeService = game:GetService("BadgeService")
local BadgeId = 2397498599913242
local PlayerData = DataStoreService:GetDataStore("PlayerData")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage.Events.MoreUiEvents.MostTime
local CarlId = "Player_1822147878"
local Carl = PlayerData:GetAsync(CarlId)
if Carl then
Event:FireAllClients(Carl[2])
else
Event:FireAllClients(0)
end
Event.OnServerEvent:Connect(function(plr, Type, Time)
if Type == "BoxWatch" then
if Time >= Carl[2] then
BadgeService:AwardBadge(plr, BadgeId)
end
end
end)
Any help is appreciated.