I’m trying to make it so when this developer product is purchased, the player’s team changes and it respawns them, though so far I’ve been unsuccessful. I’ve managed to get this all written down, but once purchased nothing happens and no errors are left behind either. Any clues as to why?
local MarketplaceService = game:GetService("MarketplaceService")
local ProductID = 000
MarketplaceService.PromptPurchaseFinished:Connect(function(Player, ID, Purchased)
if Player and ID == ProductID and Purchased then
local Humanoid = Player.Character:WaitForChild("Humanoid")
Player.TeamColor = BrickColor.new("Bright yellow")
Humanoid.Health = 0
end
end)
• Try using PromptPurchaseFinished Event, Anyways. Here’s the solution, you can also replace PromptPurchaseFinished with PromptGamePassPurchaseFinished If you certainly prefer that!
MarketplaceService.PromptPurchaseFinished:Connect(function(Player, ID, Purchased)
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, ID, Purchased)
• Are equivalent, but with a different event name.
I’m getting the following error in the developer console with your script
ServerScriptService.TPScript:4: attempt to index function with ‘connect’
That’s strange, Hold on Let me get on it real quick.
local MarketplaceService = game:GetService("MarketplaceService")
local ProductID = 000
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(Player, ID, Purchased)
if Purchased and ID == ProductID then
local Humanoid = Player.Character:WaitForChild("Humanoid")
Player.TeamColor = BrickColor.new("Bright yellow")
Humanoid.Health = 0
end
end)
I did a little bit of edit, Wanna test it out?
Still isn’t working for some reason, though I’m not entirely sure if it’s the script this time. I’ve been getting an error saying “HttpError: ConnectFail.” im kinda new to scripting though so not 100% sure if that means much.
Will you show me the error, So that I can check your problem.
That’s not actually the error coming from MarketplaceService, Or is it?
Try running this in a Command Bar after playing in client.
local ProductID = 000
game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, ProductID)
OOPS! My bad, I mispelled “Prompt”. I editted the code you were suppose to copy and run it in a command bar.
Make sure you’re fulfilling this inside studio.
Hmmm, Try replacing LocalPlayer
to your username. This is a purchase test. Make sure that the PromptGamePassPurchasedFinished Event is still there.
No gui pops up? This is getting interesting.
the gui pops up and I’m able to confirm the purchase and all that, it’s just the team changing part that doesnt seem to work
Try changing the event to
MarketplaceService.PromptPurchaseFinished:Connect(function(Player, ID, Purchased)