Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. --[[
  2.  
  3. DO NOT EDIT, YOU MAY EDIT "Settings" Module script.
  4.  
  5. --]]
  6.  
  7.  
  8.  
  9. local Tycoons = {}
  10.  
  11. local Teams = game:GetService('Teams')
  12.  
  13. local Settings = require(script.ParentSettings)
  14.  
  15. local BC = BrickColor
  16.  
  17. local Storage = Instance.new('Folder',game.ReplicatedStorage)
  18.  
  19. Storage.Name = "PlayerMoney"
  20.  
  21. Instance.new('Model',workspace).name = "PartStorage" --Parts dropped go here!
  22.  
  23.  
  24.  
  25. function returnColorTaken(color)
  26.  
  27. for i,v in pairs(Teams:GetChildren()) do
  28.  
  29. if v:IsA('Team') then
  30.  
  31. if v.TeamColor == color then
  32.  
  33. return true
  34.  
  35. end
  36.  
  37. end
  38.  
  39. end
  40.  
  41. return false
  42.  
  43. end
  44.  
  45.  
  46.  
  47. if not Settings('AutoAssignTeam') then
  48.  
  49. local teamHire = Instance.new('Team', Teams)
  50.  
  51. teamHire.TeamColor = BC.new('White')
  52.  
  53. teamHire.Name = "For Hire!"
  54.  
  55. end
  56.  
  57.  
  58.  
  59. for i,v in pairs(script.Parent:WaitForChild("Tycoons"):GetChildren())do
  60.  
  61. Tycoons[v.Name] = v.Clone()
  62.  
  63. if returnColorTaken(v.TeamColor) then
  64.  
  65. local newColor;
  66.  
  67. repeat
  68.  
  69. wait()
  70.  
  71. newColor = BC.Random()
  72.  
  73. until returnColorTaken(newColor) == false
  74.  
  75. v.TeamColor.Value = newColor
  76.  
  77. end
  78.  
  79. local NewTeam = Instance.new('Team',Teams)
  80.  
  81. NewTeam.Name = v.Name
  82.  
  83. NewTeam.TeamColor = v.TeamColor.Value
  84.  
  85. if not Settings['AutoAssignTeams'] then
  86.  
  87. NewTeam.AutoAssignable = false
  88.  
  89. end
  90.  
  91. v.PurchaseHandler.Disabled = false
  92.  
  93. end
  94.  
  95.  
  96.  
  97. function getPlrTycoon(Player)
  98.  
  99. for i,v in pairs(script.Parent.Tycoons:GetChildren()) do
  100.  
  101. if v:IsA("Model") then
  102.  
  103. if v.Owner.Value == Player then
  104.  
  105. return v
  106.  
  107. end
  108.  
  109. end
  110.  
  111. end
  112.  
  113. return nil
  114.  
  115. end
  116.  
  117.  
  118.  
  119. game.Players.Added:connect(function(player)
  120.  
  121. local plrStats = Instance.new("NumberValue",game.ReplicatedStorage.PlayerMoney)
  122.  
  123. plrStats.Name = player.name
  124.  
  125. local isOwner = Instance.new("ObjectValue",plrStats)
  126.  
  127. isOwner.Name = "OwnsTycoon"
  128.  
  129. end)
  130.  
  131.  
  132.  
  133. game.Players.PlayerRemoveing:connect(function(player)
  134.  
  135. local plrStats = game.ReplicatedStorage.PlayerMoney:FindFirstChild(player.Name)
  136.  
  137. if plrStats ~=nil then
  138.  
  139. plrStats:Destroy()
  140.  
  141. end
  142.  
  143. local tycoon = getPlrTycoon(player)
  144.  
  145. if tycoon then
  146.  
  147. local backup = Tycoons(tycoon.Name):Clone()
  148.  
  149. tycoon:Destroy()
  150.  
  151. wait()
  152.  
  153. backup.Parent = script.Parent.Tycoons
  154.  
  155. end
  156.  
  157. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement