Hello devforum members
I made a few gamepass’ and used these scripts to make it so that when players buy the gamepass while in game, they obtain the items that comes with it while playing.
The problem with the script is that instead of only giving the items that are supposed to come with the specific gamepass, it gives the player the items of every other gamepass as well. I tested it out and it happens with every gamepass I use it for even if I try to put the tools in a folder to try and specifically only take the weapons from that folder.
Here are the scripts I used:
In the GUI section:
local mps = game:GetService("MarketplaceService")
local gamepass_id = 0
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)
in the SeverScriptService section:
local mps = game:GetService("MarketplaceService")
local gamepass_id = 0
game.Players.PlayerAdded:Connect(function(player)
if mps:UserOwnsGamePassAsync(player.UserId, gamepass_id) then
game.ServerStorage.speedcoil.AccelerationCoil:Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage.speedcoil.AccelerationCoil:Clone().Parent = player:WaitForChild("StarterGear")
end
end)
game.ReplicatedStorage.Give.OnServerEvent:connect(function(player)
game.ServerStorage.speedcoil.AccelerationCoil:Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage.speedcoil.AccelerationCoil:Clone().Parent = player:WaitForChild("StarterGear")
end)