Hello!, So i want to create a timer when it passes it will give player a badge
for example: When it 8 am → 8h30am it will give player a badge
Code:
local Badgeservice = game:GetService(“BadgeService”)
local id = 2124535394
local value = script.TimeValue
game.Players.PlayerAdded:Connect(function(plr)
while wait() do
if value == 1800
then
Badgeservice:AwardBadge(plr.UserId, id) print(“30 mins pass”)
end
end
end)
Okay so I read the Wiki and got basic knowledge on what you’re trying to do.
First off, you want to get BadgeService [ which you did ]
Afterwards, make a function to award the badge [ to make it neater ]
Get the current hour using os.date
Make a PlayerAdded function
I made a quick example for you that will run if it’s 3PM, here.
local BadgeService = game:GetService("BadgeService")
function awardBadge(player, badgeId)
if BadgeService:IsLegal(badgeId) and not BadgeService:IsDisabled(badgeId) then
BadgeService:AwardBadge(player.UserId, badgeId)
end
end
local currentHour = os.date("*t")["hour"]
game:GetService("Players").PlayerAdded:connect(function(plr)
if currentHour == 15 then -- if it's 3PM
print("it's currently 3PM")
awardBadge(plr, 2124535394)
else
print("it's not 3PM")
return
end
end)
Use this example, analyze it and let me know if it solves your problem.