Script won't award badge

Hello.
I have this script, where it opens a gift live in a server, and award everyone playing with a badge.
The gift opens, but the badge awarding part doesn’t work.

Script:

local model = script.Parent

local specifiedDate = os.time({year = 2023, month = 12, day = 23, hour = 6, min = 36, sec = 0})  -- Change the date to the specified date

local badge = 1419255965342856 -- WHY ARE IDS OF NEW BADGES THIS LONG NOW LIKE WHAT

local badgeservice = game:GetService("BadgeService")

local players = game:GetService("Players")

local function checkDate()
	local currentDate = os.time()
	if currentDate >= specifiedDate then
		game.ServerStorage.car1.Parent = game.Workspace
		game.ServerStorage.car2.Parent = game.Workspace
		
		wait(1)
		for _, welds in pairs(script.Parent:GetChildren()) do
			if welds:IsA("WeldConstraint") then
				welds:Destroy()
			end
		end
		
		local playerlist = players:GetPlayers()
		for _, player in pairs(playerlist) do
			badgeservice:AwardBadge(player.UserId, badge)
		end
		
		game.Players.PlayerAdded:Connect(function(plr)
			badgeservice:AwardBadge(plr.UserId, badge)
		end)
	end
end

-- Check the date every second
while wait(1) do
	checkDate()
end
4 Likes

Any errors? Also, try to add prints before the AwardBadge to see if they even run in the first place.

1 Like

Can you set os.time? And why would you want to if you are trying to see if a date is after it?

Why not make your specifiedDate the date you want without using os.time.
That way you are comparing {year = 2023, month = 12, day = 23, hour = 6, min = 36, sec = 0} to actual os.time.

As @Pure_Bacn said, put a print statement before you use each variable for troubleshooting. For example print(specifiedDate, " ", os.time())

1 Like

Are you sure that the badge ID is correct / the badge is able to be awarded? When I replaced it with the I’d of another page in the webbrowser it redirects me to a 404 Error page

1 Like

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