Problem about Badge

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)

inside the script is the TimeValue

About the day and night script:

lightning = game.Lighting

while wait(0.5) do

lightning:SetMinutesAfterMidnight(lightning:GetMinutesAfterMidnight() + 0.5)

end

There was no errors , Thanks for helping me .

When you say like ( e.g. 8AM ) do you mean in terms of game time or actual time?

here should be if value.Value == 1800

I mean actual time. Not game time

Right I’ll give you an example, one sec.

Also I would change this whole part into:

value.Changed:Connect(function()
if value.Value == 1800
then
Badgeservice:AwardBadge(plr.UserId, id) print(“30 mins pass”)
end
end)
end)

To save some preformance.

Okay so I read the Wiki and got basic knowledge on what you’re trying to do.

  1. First off, you want to get BadgeService [ which you did ]
  2. Afterwards, make a function to award the badge [ to make it neater ]
  3. Get the current hour using os.date
  4. 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.

Hey @Aldanium i think it was my mistake, sorry!, i mean like , when it passes 30 minutes it will give player badge, by using the code bellow :smiley:

I would advise you to go to this and read up on it as it might help.

A few if checks should be able to get you on track for this project.

Thanks @Aldanium . The problem solved! :smiling_face_with_three_hearts: