Advertisement
Guest User

Untitled

a guest
Jun 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. --Server Script:
  2.  
  3. local ms = game:GetService("MarketplaceService")
  4. local gamePassRF = game:GetService("ReplicatedStorage"):WaitForChild("GamePassRF")
  5. local vipBoughtRE = game:GetService("ReplicatedStorage"):WaitForChild("VipBoughtRE")
  6.  
  7. function purchaseDone(player, id, success)
  8.     if success and id == 4604785 then
  9.         vipBoughtRE:FireClient(player)
  10.     end
  11. end
  12.  
  13. function hasPass(player, id)
  14.     return ms:UserOwnsGamePassAsync(player.UserId, id)
  15. end
  16.  
  17. gamePassRF.OnServerInvoke = hasPass
  18. ms.PromptGamePassPurchaseFinished:Connect(purchaseDone)
  19.  
  20. --Local Script:
  21. local player = game.Players.LocalPlayer
  22. local button = script.Parent.Frame:WaitForChild("TextButton")
  23. local gamePassRF = game:GetService("ReplicatedStorage"):WaitForChild("GamePassRF")
  24. local vipBoughtRE = game:GetService("ReplicatedStorage"):WaitForChild("VipBoughtRE")
  25. local isSped = false
  26.  
  27. local id = 4604785
  28.  
  29. local playerHasVIP = gamePassRF:InvokeServer(id)
  30.  
  31. function toggleSpeed()
  32.     if player.Character and playerHasVIP then
  33.         if isSped then
  34.             button.Text = "Speed up"
  35.             player.Character.Humanoid.WalkSpeed = 16
  36.             isSped = false
  37.         else
  38.             button.Text = "Slow down"
  39.             player.Character.Humanoid.WalkSpeed = 30
  40.             isSped = true
  41.         end
  42.     else
  43.         if not playerHasVIP then
  44.             game:GetService("MarketplaceService"):PromptGamePassPurchase(player, id)
  45.         end
  46.     end
  47. end
  48.  
  49. function purchased()
  50.     playerHasVIP = true
  51. end
  52.  
  53. vipBoughtRE.OnClientEvent:Connect(purchased)
  54. button.MouseButton1Click:Connect(toggleSpeed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement