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:
01 | local part = script.Parent |
02 | local BadgeService = game:GetService( "BadgeService" ) |
03 | local timer = 0 |
04 | if 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 ) |
14 | else |
15 | part.Transparency = 1 |
16 | timer = timer + 1 |
17 | wait( 1 ) |
18 | end |
i notice a few issues with your code, try this
01 | local part = script.Parent |
02 | local BadgeService = game:GetService( "BadgeService" ) |
03 | task.delay( 180 , function () |
04 | part.Transparency = 0 |
05 | end ) |
06 | --now for the clicking function |
07 | part.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 |
12 | end ) |
and if you want it to keep disappearing then appearing forever
01 | local part = script.Parent |
02 | local BadgeService = game:GetService( "BadgeService" ) |
03 | task.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 |
07 | end ) |
08 | --now for the clicking function again |
09 | part.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 |
14 | end ) |
NOTE: THESE WILL ONLY DISAPPEAR WHEN THEY ARE CLICKED, RATHER THAN AFTER 30 SECONDS
let me know if there are any issues