Rain on purchase of a developer product

Hello, I am trying to make sausages rain from the sky when you purchase a developer product, however I do not script so I need a bit of help, I have made the sausages rain but at the moment, they constantly rain.
I would like it to only rain for 30 seconds when you purchase the developer product.
There is a part named button you click to buy the product.

Here's some pictures of what I'm working with.

image
image
image

Can you include the script where sausages rain in your post please? We can then fit it to be able to rain for a specified amount of time.

Have a second wait that is for 30 sec then make a bool value that will change to true when the 30 sec are up. That way every time you loop the code and check if that variable is true then it will end.

Would’ve been more helpful if you posted it as a code block, but it’s fine.

function productPurchased()
 local startTime = tick()
 local rainTime = 30 --seconds
 while tick() - startTime < rainTime do
  local rainPart = game.ReplicatedStorage.RainPart.RainPart:Clone()
  rainPart.Position = Vector3.new(math.random(-200,500),500,math.random(-200,500))
  rainPart.CanCollide = false
  rainPart.Parent = game.Workspace.RainPart
  wait(0.1)
 end
end

If this solves your problem, please mark me as solution! If not, post any issues!

  1. Does this make it so it only rains on purchase of the developer product?
  2. If so where would I type the ID?
  3. Does this work with a button?

No. On the purchase of the developer product event, you will fire my function that I have created for you.
No. On the press of a button event (ClickDetector I assume?), you will fire the function that I created, or prompt a developer product purchase that when successful, calls my function.

These articles may help:

In this article right here what do I copy?
Do I put it in a local script or a normal script.
And where do I put the scripts?
Sorry if I’m asking too much of you, I just don’t understand scripting just yet.