So, basically I would like to code a script so when the player "Buy" the gamepaase in-game from a gui buttons it give directly Coil+1500 Cash.( Like so players no need to rejoin)
I coded it so when player join but I don't know how to code it so it gives directly when bought in-game.
local marketService = game:GetService'MarketplaceService'
local serverStorage = game.ServerStorage
local passId = 534934009
game.Players.PlayerAdded:connect(function(plr)
local plrCash = serverStorage.PlayerMoney[plr.Name]
if marketService:PlayerOwnsAsset(plr, passId) then
local coilGear = serverStorage.Coil:Clone()
coilGear.Parent = plr.Backpack
plrCash.Value = plrCash.Value + 1500 --VIP Perks
end
end)
This is my DevProduct/GamePasse Handler
for i,v in pairs(script.Parent.Buttons:GetChildren()) do
if v:isA("TextButton") then
v.MouseButton1Click:connect(function()
pcall(function()
if v:FindFirstChild("Pass") then
game.MarketplaceService:PromptPurchase(game.Players.LocalPlayer,tonumber(v.Name))
else
game.MarketplaceService:PromptProductPurchase(game.Players.LocalPlayer,tonumber(v.Name))
end
end)
end)
end
end
