Hello! I'm having an issue. I want a script to change the player's walkspeed when a gamepass is bought. I've tried a lot of scripts. So I've decide to ask people. Here's the script I'm working on that lets you buy it. I just need it to make you walk faster.
local player = game.Players.LocalPlayer local id = 480546823 script.Parent.MouseButton1Down:connect(function() game:GetService("MarketplaceService"):PromptPurchase( player, id) end)
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") -- Not necessary, but it's a variable for MarketplaceService. script.Parent.MouseButton1Down:connect(function() mps:PromptPurchase(player, id) end)
Server Script in ServerScriptService:
local id = 480546823 local mps = game:GetService("MarketplaceService") -- Not necessary, but it's a variable for MarketplaceService. mps.PromptPurchaseFinished:connect(function(player, assetId, isPurchased) -- The function contains 3 parameters: The player who bought the pass, the ID of the pass and a boolean to determine whether the player bought the pass. if isPurchased and assetId == id then -- If the player ACTUALLY paid for the pass. player.Character:WaitForChild("Humanoid").WalkSpeed = 20 -- Change to any speed you like. end end) -- I forgot to add a ")", sorry about that.
If you have any problems please leave a comment below. Thank you and I hope this will help you.