Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MarkeplaceService = game:GetService("MarketplaceService")
- local Players = game:GetService("Players")
- local FlipEvent = game.ReplicatedStorage:WaitForChild("FlipEvent")
- local FlipModel = game.Workspace.FlipModels
- local debounce = true
- local debounce2 = true
- local frontflipid
- local backflipid
- local connection
- for i,v in pairs(FlipModel:GetDescendants())do
- if v:IsA("Part") and v.Name == "Plate" then
- v.Touched:Connect(function(hit)
- if hit.Parent:FindFirstChild("Humanoid") and debounce then
- debounce = false
- local Player = Players:GetPlayerFromCharacter(hit.Parent)
- --print(Player)
- --print(v.FlipNameId.Value)
- local FlipNameId = v.FlipNameId.Value
- local ModelName = v.Parent.Name
- local AnimationId = v.Animate.jump.JumpAnim.AnimationId
- local ownsGamepass = game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,FlipNameId)
- local success, errormessage = pcall(ownsGamepass);
- if not ownsGamepass then
- local Purchase = game:GetService("MarketplaceService"):PromptGamePassPurchase(Player,FlipNameId)
- --print(Purchase)
- local function gamepassPurchaseFinished(Player,FlipNameId,wasPurchased)
- --Market:Disconnect()
- print(FlipNameId)
- if wasPurchased == true and debounce2 and FlipNameId then
- debounce2 = false
- Player.Character:FindFirstChild("Animate"):Destroy()
- --print(FlipNameId.Parent)
- local newAnimation = FlipModel:FindFirstChild(ModelName).Plate.Animate:Clone()
- newAnimation.Parent = Player.Character
- Player.Animations:FindFirstChild("Animation").Value = ModelName
- -- Fire Another event from the server!!
- FlipEvent:FireClient(Player,ModelName)
- wait(1)
- debounce2 = true
- connection:Disconnect()
- return
- else
- -- print("Canceled") -- noticed that the else runs a few times but thats not causing any problems
- return
- end
- end
- connection = MarkeplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)
- end
- if ownsGamepass then
- if Player.Character:FindFirstChild("Animate") and Player.Animations.Animation.Value == ModelName then -- and Player.Character:FindFirstChild("Animate").jump.JumpAnim.AnimationId == AnimationId
- Player.Character:FindFirstChild("Animate"):Destroy()
- wait(.1)
- local ReplaceAnimation = FlipModel.Animate:Clone()
- ReplaceAnimation.Parent = Player.Character
- Player.Animations:FindFirstChild("Animation").Value = ""
- -- fire client
- FlipEvent:FireClient(Player,ModelName)
- else
- Player.Character:FindFirstChild("Animate"):Destroy()
- local newReplaceAnimation = FlipModel:FindFirstChild(ModelName).Plate.Animate:Clone()
- newReplaceAnimation.Parent = Player.Character
- Player.Animations:FindFirstChild("Animation").Value = ModelName
- -- fire client
- FlipEvent:FireClient(Player,ModelName)
- end
- end
- wait(1)
- debounce = true
- end
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement