Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hammer won't appear when the 3 minute timer is finished?

Asked by 2 years ago
Edited 2 years ago

I'm having trouble getting this script to work, I need it to wait 3 minutes then it will show up and give the player the chance to click it. When it is clicked, it shouldn't be able to be clicked again and instead wait 3 minutes again, this will also give a badge when clicked. This is located inside the part I want to be clicked, and no, it isn't a local script. The problem is that it just will never show up and stay in the state of the waiting 3 minutes part forever. Here it is:

01local part = script.Parent
02local BadgeService = game:GetService("BadgeService")
03local timer = 0
04if timer == 180 then
05    part.Transparency = 0
06    while wait(30) do
07        part.ClickDetector.MouseClick:Connect(function(player)
08            BadgeService:AwardBadge(player.UserId, 4411773994)
09            part.Transparency = 1
10        end)
11    end
12    part.Transparency = 1
13    wait(1)
14else
15    part.Transparency = 1
16    timer = timer + 1
17    wait(1)
18end

1 answer

Log in to vote
1
Answered by 2 years ago

i notice a few issues with your code, try this

01local part = script.Parent
02local BadgeService = game:GetService("BadgeService")
03task.delay(180, function()
04    part.Transparency = 0
05end)
06--now for the clicking function
07part.ClickDetector.MouseClick:Connect(function(player)
08    if part.Transparency == 0 then
09        BadgeService:AwardBadge(player.UserId, BADGEID) --you NEED to replace BADGEID with a valid badge id, as the one in your code is not so valid
10        part.Transparency = 1
11    end
12end)

and if you want it to keep disappearing then appearing forever

01local part = script.Parent
02local BadgeService = game:GetService("BadgeService")
03task.delay(0, function() --not the best way to stop yielding, but its how i do it
04    while task.wait(180) do
05        part.Transparency = 0
06    end
07end)
08--now for the clicking function again
09part.ClickDetector.MouseClick:Connect(function(player)
10    if part.Transparency == 0 then
11        BadgeService:AwardBadge(player.UserId, BADGEID) --you NEED to replace BADGEID with a valid badge id, as the one in your code is not so valid
12        part.Transparency = 1
13    end
14end)

NOTE: THESE WILL ONLY DISAPPEAR WHEN THEY ARE CLICKED, RATHER THAN AFTER 30 SECONDS

let me know if there are any issues

0
ok thanks so much i'lltry it Puppy_lovertheawsome 84 — 2y
Ad

Answer this question