Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Setup
- local PurchaseFunctions = {};
- --[[
- Function: GiveCash
- Description: Give a specified amount of cash when purchased
- Option: Amount of cash to give
- Function: GiveMaxHealth
- Description: Raises max health
- Option: Amount of health to be added on top of the 100.
- Function: GiveSpeed
- Description: Increases walkspeed
- Option: Amount of speed to add onto base speed (16)
- Function: GiveGear
- Description: Puts a gear into player's backpack
- Option: Name of the gear
- Option2: Put true if it saves when you die, false if it's only for one life.
- --]]
- -- Tip: Changing 'Name' doesn't do anything, it's just for organizational purposes.
- local Gamepasses = {
- { Name="Give Minigun Permanently"; ID=12345; Function="GiveGear"; Option="Minigun"; Option2=true; };
- };
- local DeveloperProducts = {
- { Name="Give 50 Cash"; ID=00000; Function="GiveCash"; Option=50; }; -- Don't forget this symbol ;
- { Name="Give 25 Max Health"; ID=0000; Function="GiveMaxHealth"; Option = 25; };
- { Name="Give 5 WalkSpeed"; ID=0000; Function="GiveSpeed"; Option = 5; };
- { Name="Give Minigun Temporarily"; ID=0000; Function="GiveGear"; Option="Minigun"; Option2=false; };
- };
- -- Tip: 'Username' is not used, it's just to keep track of who you're giving passes to because UserIDs are hard to remember!
- -- Tip: You can use this to test the gamepasses without buying or even making them, the ID can be fake and it'll still work.
- local FreePasses = {
- { Username="Player1"; UserID=-1; Passes={ 12345,11111,595959 }; };
- { Username="Nikilis"; UserID=1848960; Passes={ 12345,11111,595959 }; };
- { Username="Thexz"; UserID=4242824; Passes={ 12345,11111,595959 }; };
- }
- -- Nothing below to edit
- local MarketplaceService = game:GetService("MarketplaceService")
- local Keys = {};
- function MarketplaceService.ProcessReceipt(ReceiptInfo)
- local playerProductKey = ReceiptInfo.PlayerId .. ":" .. ReceiptInfo.PurchaseId
- if Keys[playerProductKey] then return Enum.ProductPurchaseDecision.PurchaseGranted; end
- local Player = game:GetService("Players"):GetPlayerByUserId(ReceiptInfo.PlayerId)
- if not Player then return Enum.ProductPurchaseDecision.NotProcessedYet; end
- for _,ProductData in pairs(DeveloperProducts) do
- if ProductData.ID == ReceiptInfo.ProductId then
- PurchaseFunctions[ProductData.Function](Player,ProductData.Option,ProductData.Option2);
- Keys[playerProductKey] = true;
- return Enum.ProductPurchaseDecision.PurchaseGranted
- end
- end
- return Enum.ProductPurchaseDecision.NotProcessedYet
- end
- local MaxHealths = {};
- local Speeds = {};
- PurchaseFunctions.GiveCash = function( Target, Option )
- Target.leaderstats.Cash.Value = Target.leaderstats.Cash.Value + Option;
- end
- PurchaseFunctions.GiveMaxHealth = function( Target, Option )
- MaxHealths[Target] = (MaxHealths[Target] and MaxHealths[Target]+Option) or Option;
- Target.Character.Humanoid.MaxHealth = 100 + MaxHealths[Target];
- end
- PurchaseFunctions.GiveSpeed = function( Target, Option )
- Speeds[Target] = (Speeds[Target] and Speeds[Target]+Option) or Option;
- Target.Character.Humanoid.WalkSpeed = 16 + Speeds[Target];
- end
- PurchaseFunctions.GiveGear = function( Target, Gear, Permanent )
- game.ServerStorage.Gear[Gear]:Clone().Parent = Target.Backpack;
- if Permanent then
- game.ServerStorage.Gear[Gear]:Clone().Parent = Target.StarterGear;
- end
- end
- local function Debug(Player,Function,Option,Option2)
- PurchaseFunctions[Function](Player,Option,Option2);
- end
- local Debugger = Instance.new("RemoteEvent")
- Debugger.Name = "PurchaseDebugger";
- Debugger.Parent = game.ReplicatedStorage;
- game.Players.PlayerAdded:connect(function(Player)
- Player.CharacterAdded:connect(function(Character)
- Character:WaitForChild("Humanoid").MaxHealth = 100 + (MaxHealths[Player] or 0);
- Character:WaitForChild("Humanoid").WalkSpeed = 16 + (Speeds[Player] or 0);
- end)
- repeat wait(); until Player.Character~=nil;
- for _,GamepassData in pairs(Gamepasses) do
- local HasFreePass = false;
- for _,PD in pairs(FreePasses) do
- if PD.UserID == Player.userId then
- for _,ID in pairs(PD.Passes) do
- if ID == GamepassData.ID then
- HasFreePass = true;
- end
- end
- end;
- end
- if HasFreePass or MarketplaceService:PlayerOwnsAsset(GamepassData.ID) then
- PurchaseFunctions[GamepassData.Function](Player,GamepassData.Option,GamepassData.Option2);
- end
- end;
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement