I made a script that is meant to check if a player has two different gamepasses but the script isn’t working. I am pretty new so there is probably a problem with my script that is very easy to fix but I don’t know.
local part = script.Parent
local canGet = true
local MarketplaceService = game:GetService("MarketplaceService")
local DoubleCoingamePassID = 16457854
local DoubleXPgamePassID = 16475164
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
if humanoid then
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, DoubleXPgamePassID, DoubleCoingamePassID, purchaseSuccess)
if purchaseSuccess == true and DoubleXPgamePassID and DoubleCoingamePassID and player and canGet then
canGet = false
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 20
player.leaderstats.Exp.Value = player.leaderstats.Exp.Value + 30
wait(0.25)
canGet = true
part.Touched:Connect(onTouch)
else
if purchaseSuccess == true and DoubleXPgamePassID and player and canGet then
canGet = false
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
player.leaderstats.Exp.Value = player.leaderstats.Exp.Value + 30
wait(0.25)
canGet = true
part.Touched:Connect(onTouch)
else
if purchaseSuccess == true and DoubleCoingamePassID and player and canGet then
canGet = false
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 20
player.leaderstats.Exp.Value = player.leaderstats.Exp.Value + 15
wait(0.25)
canGet = true
part.Touched:Connect(onTouch)
else
if player and canGet then
canGet = false
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 10
player.leaderstats.Exp.Value = player.leaderstats.Exp.Value + 15
wait(0.25)
canGet = true
part.Touched:Connect(onTouch)
end
end
end
end
end)
end
end
The script is meant to check if a player has two gamepasses and if they have both then it applies both if only one then it applies one and if it doesn’t have any then it leaves it at none