Advertisement
qsenko1

Final Version of FlipGamepass

Apr 29th, 2022
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.05 KB | None | 0 0
  1. local MarkeplaceService = game:GetService("MarketplaceService")
  2. local Players = game:GetService("Players")
  3. local FlipEvent = game.ReplicatedStorage:WaitForChild("FlipEvent")
  4. local FlipModel = game.Workspace.FlipModels
  5. local debounce = true
  6. local debounce2 = true
  7. local frontflipid
  8. local backflipid
  9. local connection
  10.  
  11. for i,v in pairs(FlipModel:GetDescendants())do
  12.     if v:IsA("Part") and v.Name == "Plate" then
  13.         v.Touched:Connect(function(hit)
  14.             if hit.Parent:FindFirstChild("Humanoid") and debounce then
  15.                 debounce = false
  16.                 local Player = Players:GetPlayerFromCharacter(hit.Parent)
  17.                 --print(Player)
  18.                 --print(v.FlipNameId.Value)
  19.                 local FlipNameId = v.FlipNameId.Value
  20.                 local ModelName = v.Parent.Name
  21.                 local AnimationId = v.Animate.jump.JumpAnim.AnimationId
  22.                
  23.                 local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,FlipNameId)
  24.                 local success, errormessage = pcall(ownsGamepass);
  25.  
  26.                 if not ownsGamepass then
  27.                     local Purchase = game:GetService("MarketplaceService"):PromptGamePassPurchase(Player,FlipNameId)
  28.                     --print(Purchase)
  29.                     local function gamepassPurchaseFinished(Player,FlipNameId,wasPurchased)
  30.                         --Market:Disconnect()
  31.                         print(FlipNameId)
  32.                         if wasPurchased == true and debounce2 and FlipNameId then
  33.                             debounce2 = false
  34.                             Player.Character:FindFirstChild("Animate"):Destroy()
  35.                             --print(FlipNameId.Parent)
  36.                             local newAnimation = FlipModel:FindFirstChild(ModelName).Plate.Animate:Clone()
  37.                             newAnimation.Parent = Player.Character
  38.                             Player.Animations:FindFirstChild("Animation").Value = ModelName
  39.                             -- Fire Another event from the server!!
  40.                             FlipEvent:FireClient(Player,ModelName)
  41.                             wait(1)
  42.                            
  43.                             debounce2 = true
  44.                             connection:Disconnect()
  45.                             return
  46.                         else       
  47.                             --  print("Canceled") -- noticed that the else runs a few times but thats not causing any problems
  48.                             return
  49.                         end
  50.                     end
  51.  
  52.                     connection = MarkeplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
  53.  
  54.                 end
  55.  
  56.                 if ownsGamepass then
  57.  
  58.                     if Player.Character:FindFirstChild("Animate") and Player.Animations.Animation.Value == ModelName then -- and Player.Character:FindFirstChild("Animate").jump.JumpAnim.AnimationId == AnimationId
  59.                         Player.Character:FindFirstChild("Animate"):Destroy()
  60.                         wait(.1)
  61.                         local ReplaceAnimation = FlipModel.Animate:Clone()
  62.                         ReplaceAnimation.Parent = Player.Character
  63.                         Player.Animations:FindFirstChild("Animation").Value = ""
  64.                         -- fire client
  65.                         FlipEvent:FireClient(Player,ModelName)
  66.                     else
  67.                         Player.Character:FindFirstChild("Animate"):Destroy()
  68.                         local newReplaceAnimation = FlipModel:FindFirstChild(ModelName).Plate.Animate:Clone()
  69.                         newReplaceAnimation.Parent = Player.Character
  70.                         Player.Animations:FindFirstChild("Animation").Value = ModelName
  71.                         -- fire client
  72.                         FlipEvent:FireClient(Player,ModelName)
  73.                     end
  74.                 end
  75.                
  76.                 wait(1)
  77.  
  78.                 debounce = true
  79.        
  80.             end            
  81.         end)       
  82.     end
  83. end
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement