Facebook
From powersem2007, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 137
  1. ----------------------------------------------------------------------------------
  2. ----------------------------------------------------------------------------------
  3.  
  4. local stat = "Money" -- change Cash to the name of the stat you want to be able to donate
  5.  
  6. ----------------------------------------------------------------------------------
  7. ----------------------------------------------------------------------------------
  8.  
  9. local player = game.Players.LocalPlayer
  10. local gui = script.Parent
  11. local m = gui.Main
  12. local open = gui.Open
  13. local amount = m.Amount
  14. local plyr = m.Player
  15. local title = m.Title
  16. local donate = m.Donate
  17.  
  18. function playercheck(string)
  19. local count = 0
  20. local valid = {}
  21. for _,v in next, game.Players:GetPlayers() do
  22. if v.Name:sub(0,string:len()):lower() == string:lower() then
  23. count = count+1
  24. table.insert(valid,v)
  25. end
  26. end
  27. if count == 1 then
  28. return valid[1]
  29. end
  30. return false
  31. end
  32.  
  33. open.MouseButton1Click:connect(function()
  34. if m.Visible then
  35. m.Visible = false
  36. open.Text = "Open Donate"
  37. else
  38. m.Visible = true
  39. open.Text = "Close Donate"
  40. end
  41. end)
  42.  
  43. donate.MouseButton1Click:connect(function()
  44. local donateamount = tonumber(amount.Text)
  45. if donateamount and donateamount>0 then
  46. local donateplayer = playercheck(plyr.Text)
  47. if donateplayer then
  48. if player.leaderstats[stat].Value >= donateamount then
  49. player.leaderstats[stat].Value = player.leaderstats[stat].Value - donateamount
  50. donateplayer.leaderstats[stat].Value = donateplayer.leaderstats[stat].Value + donateamount
  51. else
  52. title.Text = "You don't have enough "..stat.."."
  53. wait(2)
  54. title.Text = "Donate"
  55. end
  56. else
  57. title.Text = "Not a valid player"
  58. wait(2)
  59. title.Text = "Donate"
  60. end
  61. else
  62. title.Text = "Not a valid amount"
  63. wait(2)
  64. title.Text = "Donate"
  65. end
  66. end)
  67.