im kind of new to scripting so please dont judge, i’ve tried alot of solutions on this forum but non of them worked, whenever the prompt finished, doesnt matter if the player bought it or not he still gets the 2x speed.
script.Parent.MouseButton1Click:Connect(function(plr)
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = game.Players.LocalPlayer
local char = player.Character
local productID = 26100589
MarketplaceService:PromptGamePassPurchase(player, productID)
if MarketplaceService.PromptGamePassPurchaseFinished then
local Humanoid = char:FindFirstChild("Humanoid")
Humanoid.WalkSpeed = game.StarterPlayer.CharacterWalkSpeed * 2
end
end)
yea i kind of figured it out myself but i forgot what i replaced it with cuz i found that specific line from a solution here. and i still cant find a solution that will fix it
Put this in a server script, so you can handle all your gamepasses in one placed.
local MPS = game:GetService("MarketplaceService")
MPS.PromptGamePassPurchaseFinished:Connect(function(player, gamepassID, purchased)
if purchased then
if gamepassID == 0000000 then
--code
end
end
end)
script.Parent.MouseButton1Click:Connect(function()
local MPS = game:GetService("MarketplaceService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local ProductID = 26100589
MPS:PromptGamePassPurchase(Player.UserId, ProductID)
local function purchaseFinished()
local Humanoid = Character:FindFirstChild("Humanoid")
Humanoid.WalkSpeed = 32
end
MPS.PromptGamePassPurchaseFinished:Connect(function(player, gamePassId, wasPurchased)
if wasPurchased == true and gamePassId == ProductID then
purchaseFinished()
end
end
end)