So, basically I decided to check out a Roblox document about marketplaceservice:promptpurchase. I got this weird error stating:
MarketplaceService:PromptProductPurchase() player should be of type Player, but is of type Players
If it has to be a local script, I cant do that since proximity prompt doesn't work for local scripts.
Script:
local ProximityPrompt = script.Parent local player = game:getService("Players") local productId = 1164763860 ProximityPrompt.Triggered:Connect(function() game:GetService("MarketplaceService"):PromptProductPurchase(player, productId) if productId == 1164763860 then print("Test") elseif productId == 1164763860 then print("Test") end end)
You're trying to prompt the whole players service to buy your product. You should instead prompt a player, or run a for loop through game.Players:GetPlayers() to prompt everyone.
local ProximityPrompt = script.Parent local productId = 1164763860 ProximityPrompt.Triggered:Connect(function(player) -- player that activated it. game:GetService("MarketplaceService"):PromptProductPurchase(player, productId) -- deleted rest of code because it does nothing hehe end)
You should rather try using a ClickDetector function in your brick so it can easily accessed from LocalScript. Otherwise the prompt will fire in everyone becaues you are using :GetPlayers which is all the players
if you want to use touched event or want to get a pro move then use remote event, using :FireClient and from the localscript get the client using :OnClientEvent
Also player is a service, not a player, you should use LocalScript to access the player in Players service or get them using a player added event and get the player parameter
if you dont know what i mean just ask me go ahead