How to spawn a model when a developer product is bought?

So, I want to detect if a player has bought a developer product and then spawn a mesh part in ServerStorage any ideas?
This is the script inside of the tsunami

--Variables--
local Brick = script.Parent
--End--

--Code--
local function PlayerTouched(Part)
	local Parent = Part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		Parent.Humanoid.Health = 0
	end
end

Brick.Touched:connect(PlayerTouched)
local sp = script.Parent.Speed.Value

while true do
	script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -sp)
	wait()
end

and a IntValue for the speed

You’ll want to use MarketPlaceService:PromptProductPurchase to prompt a player to buy a developer product. You can use MarketPlaceService.ProcessReceipt to detect when they finish the purchase.

and then can i just run the clone script to clone the model into workspace?

I’m not exactly sure what you’re doing, but yes. The second link I sent has a code sample at the bottom that you may find helpful.

im using it so if a player buys it it spawns a tsunami that uses CFrame to travel across the baseplate

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