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

Roblox marketplace system is not showing when a brick is touched?

Not to big a fix here but in my game I have a part, when the part is touched the player can donate for 20 robux, somehow my code isn't working, there have been no errors in output. The script is a local script. Its parent is the brick the player touches. Its a really simple script, I have zero clue why it didn't work, thank you.

local id = 1113057306

script.Parent.Touched:Connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer,id)
end)

4 comments

0

you might have misspelled id, or Touched event doesn't work in a local script. Use a remote event and fireClient it.

0

Is it a gamepass or developer product?

0

dev product

0

Local Scripts don't work on Workspace

2 answers

✓ Accepted answer

Hey TGA, You would be better firing it in a script inside the part and not a local script.

The touched function has a very special parameter that detects what part hit it. We can use this to detect if a player has touched it.

This is a script I have tested and it works:

local id = 1113057306

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players[hit.Parent.Name]
		game:GetService("MarketplaceService"):PromptProductPurchase(player, id)
	end
end)

Hope this helped you!

If it did please mark this as the solution so it helps others.

Liked my answer? Consider giving me an upvote

Cheers, orcazate

1 comment

0

cheers man, i've given you a upvote and followed you on roblox :)

The problem is that you're using a local script, and local scripts don't run in the Workspace.

Local Scripts run on:

  1. The player's GUI.
  2. The player's Starter's scripts.
  3. In a tool.
  4. In Replicated First.

Instead, use a normal script, becuase the donation prompt will just fire for the player that touched, and not for the entire server.

local id = 1113057306

script.Parent.Touched:Connect(function(hit)
   if hit.Parent:FindFirstChild("Humanoid")then -- Checks if what hits the part is a player's character --
  	  local player = hit.Parent.Name
 	   game:GetService("MarketplaceService"):PromptProductPurchase(player,id)
end)

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