Best way to do this?

I want to make a lucky block where you reach the end of the obby and you have to wait a specific amount of time to be able to claim a lucky block. But I’m not too sure what the best way to do this would be. I can script a lucky block using math.random but I don’t know how I could add a timer to it.

Should I put a part around the lucky block and add a timer to that part and when the timer goes off I can claim the lucky block? Someone please help

How does the player claim the lucky block currently?

1 Like

by touching it

characters characters char char

You could just connect the Touched event when a timer ends then?

There are 2 ways for you to approach this:

  1. When player touches a part which is at the end of obby trigger a remote event and listen for it in another script:
event.OnServerEvent:Connect(function(player)
task.wait(5)
--Lucky Block code
end)
  1. Create a function in your mainscript as your lucky block code and then do this in your main script:
endPart.Touched:Connect(function(player)
task.wait(5)
-- Lucky Block code
end)

How could I code a timer and when the timer ends I can claim the part? Could I just connect the timer to a part surrounding the lucky block?

You could use task.wait as a timer and so the code after task.wait will only execute when the wait is over

Ok, I can make the timer so I’ll do your idea, ty

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.