Your first part for PromptPurchase is done! Good job!
Now, for the second part, making the effects.
We use the PromptPurchaseFinished event which can be accessed in MarketplaceService. Then, we connect it with a function which will give the game effects to the buyers (players who bought the pass).
Here are the edited scripts:
LocalScript in a button:
local player = game.Players.LocalPlayer
local id = 480546823
local mps = game:GetService("MarketplaceService")
script.Parent.MouseButton1Down:connect(function()
mps:PromptPurchase(player, id)
end)
Server Script in ServerScriptService:
local id = 480546823
local mps = game:GetService("MarketplaceService")
mps.PromptPurchaseFinished:connect(function(player, assetId, isPurchased)
if isPurchased and assetId == id then
player.Character:WaitForChild("Humanoid").WalkSpeed = 20
end
end)
If you have any problems please leave a comment below. Thank you and I hope this will help you.
5 comments
It didn't work. But I think I know why, I put a LocalScript under a button GUI, so when you hit the button it gives you the message to buy it. Does that have something to do with it?
its better to leave the last part (9-13) being handled by a serverside script
I updated the script, take a look again.
doesnt work, i had a friend test it and it didnt work for him...
how can it not work, like any errors or problems?