Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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:

local part = script.Parent
local BadgeService = game:GetService("BadgeService")
local timer = 0
if timer == 180 then
	part.Transparency = 0
	while wait(30) do
		part.ClickDetector.MouseClick:Connect(function(player)
			BadgeService:AwardBadge(player.UserId, 4411773994)
			part.Transparency = 1
		end)
	end
	part.Transparency = 1
	wait(1)
else
	part.Transparency = 1
	timer = timer + 1
	wait(1)
end

1 answer

✓ Accepted answer

i notice a few issues with your code, try this

local part = script.Parent
local BadgeService = game:GetService("BadgeService")
task.delay(180, function()
	part.Transparency = 0
end)
--now for the clicking function
part.ClickDetector.MouseClick:Connect(function(player)
	if part.Transparency == 0 then
		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
		part.Transparency = 1
	end
end)

and if you want it to keep disappearing then appearing forever

local part = script.Parent
local BadgeService = game:GetService("BadgeService")
task.delay(0, function() --not the best way to stop yielding, but its how i do it
	while task.wait(180) do
		part.Transparency = 0
	end
end)
--now for the clicking function again
part.ClickDetector.MouseClick:Connect(function(player)
	if part.Transparency == 0 then
		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
		part.Transparency = 1
	end
end)

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

let me know if there are any issues

1 comment

0

ok thanks so much i'lltry it

This discussion is preserved as it was. New answers, comments, and votes are closed.