Hello,
I am making a custom badge award ui, because roblox’s badge award UI doesn’t support custom badge descriptions.
However, when trying to do this, I keep running into the same exact issue. “Value of nil can not be converted into number.”
Here’s the kicker: I’m passing a number, and the badge itself awards, but the rest of the script seems to not work.
I’ve tried everything, but I can’t find a solution to this issue at all. This is either a weird roblox lua bug, or something else…
MODULE SCRIPT:
local module = {}
local bs = game:GetService("BadgeService")
local bag = script.badgeAwardedGui
function module.AwardBadge(userid, badgeid)
bs:AwardBadge(userid, badgeid)
if typeof(userid) ~= "number" then
warn("userids gotta be a numero pal")
end
if typeof(badgeid) ~= "number" then
warn("badge gotta be a numero pal")
end
local plr = game.Players:GetPlayerByUserId(userid)
local ui = bag:Clone()
if plr then
ui.Parent = plr.PlayerGui
else
warn("No Player.")
ui:Destroy()
end
local yay, nay = pcall(function()
local badgeInfo = bs:GetBadgeInfoAsync(badgeid)
ui.BadgeName.Value = badgeInfo.Name
ui.BadgeDesc.Value = badgeInfo.Description
ui.BadgeImageID.Value = badgeInfo.IconImageID
end)
if nay then
warn(nay)
ui.BadgeName.Value = tostring(badgeid)
ui.BadgeDesc.Value = nay
ui.BadgeImageID.Value = "rbxassetid://2592670412"
end
end
return module
SERVER SCRIPT:
local bs = require(game.Workspace:WaitForChild("ModuleScript"))
task.wait(5)
for i,v in pairs(game.Players:GetPlayers()) do
bs.AwardBadge(v.UserId, 2123456789)
end