Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When Gamepass bought you get tool! [MY SCRIPT NOT WORKING WHY?]

Asked by 4 years ago
Edited 4 years ago
local mps = game:GetService("MarketplaceService")
local gamepass_id = 7142544

game.Players.PlayerAdded:Connect(function(player)
 if mps:UserOwnsGamePassAsync(player.UserId, gamepass_id) then
  game.ServerStorage.Gun:Clone().Parent = player:WaitForChild("Backpack")
  game.ServerStorage.Gun:Clone().Parent = player:WaitForChild("PlayerGear")
 end
end)


game.ReplicatedStorage.Give.OnServerEvent:connect(function(player)
 game.ServerStorage.Gun:Clone().Parent = player:WaitForChild("Backpack")
 game.ServerStorage.Gun:Clone().Parent = player:WaitForChild("PlayerGear")
end)
---------------------------------------------
And here's The second one!
---------------------------------------------
local mps = game:GetService("MarketplaceService")
local gamepass_id = 7142544

script.Parent.MouseButton1Click:connect(function()
 local player = game.Players.LocalPlayer
 mps:PromptGamePassPurchase(player, gamepass_id)
end)

mps.PromptGamePassPurchaseFinished:connect(function(player, id, purchased)
 if id == gamepass_id and purchased then
  game.ReplicatedStorage.Give:FireServer()
 end
end)
0
format your code BashGuy10 384 — 4y
0
how? Techo_Dev 2 — 4y
0
there Techo_Dev 2 — 4y

1 answer

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
4 years ago

Do you have your process receipt function set up? According to this page,

"For developer product purchase prompts, connect to >MarketplaceService.PromptProductPurchaseFinished. In order to process such purchases you >need to set the ProcessReceipt callback in a single script."

Also, check if the gamepass was purchased on the server instead of firing an event from the player. Hackers can just fire that event and it acts like they bought the gamepass.

0
ok thx Techo_Dev 2 — 4y
0
no problem tell me if you need any more help and sorry for the bad formatting royaltoe 5144 — 4y
Ad

Answer this question