Advertisement
Guest User

Untitled

a guest
Dec 27th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. local stats = game:GetService("DataStoreService"):GetDataStore("Stats")
  2. houseOffset = 1
  3. GroupTime = 300 --Time it takes to get 500 Veza by being in group
  4. math.randomseed(tick())
  5. --------VEZA SPAWNING
  6. ChancesOfFindingVeza = 2/3 --Percent of locations that will have vezas
  7. ChancesOfGettingRare = 35 --Percent of getting the gold rare vize [Currently 35%]
  8. RegenTime = 300 --Amount of seconds the veza spawns
  9. --------VEZA SPAWNING
  10.  
  11. game.Players.PlayerAdded:connect(function(p)
  12. coroutine.resume(coroutine.create(function()
  13. p:WaitForChild("Backpack")
  14. local event333 = Instance.new("RemoteEvent")
  15. event333.Parent = p.Backpack
  16. event333.Name = "ShowFearRewards"
  17. repeat wait() until p.Character ~= nil
  18. wait(3)
  19. event333:FireClient(p)
  20. end))
  21. local stats = game:GetService("DataStoreService"):GetDataStore("Stats")
  22. local config = script.Config:Clone()
  23. if p:IsInGroup(72321) then
  24. local asdf = Instance.new("IntValue",p)-----------------
  25. asdf.Name = "GroupTimer"-----------------
  26. asdf.Value = GroupTime------------------------------------------------
  27. coroutine.resume(coroutine.create(function()
  28. while wait() do
  29. for i=asdf.Value,0,-1 do
  30. asdf.Value = i
  31. wait(1)
  32. end
  33. p.Config.Veza.Value = p.Config.Veza.Value + 750
  34. asdf.Value = GroupTime
  35. end
  36. end))
  37. end
  38. config.Parent = p
  39. p:WaitForDataReady()
  40. local data = stats:GetAsync(p.userId)--Loading
  41. config.House.Changed:connect(function()
  42. game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
  43. local house = Workspace.Houses:FindFirstChild(p.Name.."'s house")
  44. if house ~= nil then
  45. house:Destroy()
  46. end
  47. if config.House.Value ~= 0 then
  48. local house = nil
  49. if config.House.Value == 1 then
  50. house = game.ReplicatedStorage.ValenciaCondos:Clone()
  51. elseif config.House.Value == 2 then
  52. house = game.ReplicatedStorage.HouseName:Clone()
  53. end
  54. house.Name = p.Name.."'s house"
  55. house.Parent = Workspace.Houses
  56. house:TranslateBy(Vector3.new(0,houseOffset*100,0))
  57. houseOffset = houseOffset + 1
  58. repeat wait() until config:FindFirstChild("Base") ~= nil
  59. if config:FindFirstChild("Base") ~= nil then
  60. for i,v in pairs(config:GetChildren()) do
  61. local data23 = {}
  62. pcall(function()
  63. for ii in string.gmatch(v.Value, "%D+") do
  64. table.insert(data23,ii)
  65. end
  66. end)
  67. if string.sub(v.Name,1,4) == "Base" and house:FindFirstChild(v.Name) ~= nil then
  68. house:FindFirstChild(v.Name).BrickColor = BrickColor.new(data23[1])
  69. house:FindFirstChild(v.Name).Material = Enum.Material[tostring(data23[2])]
  70. end
  71. v.Changed:connect(function()
  72. if string.sub(v.Name,1,4) == "Base" and house:FindFirstChild(v.Name) ~= nil then
  73. house:FindFirstChild(v.Name).BrickColor = BrickColor.new(data23[1])
  74. house:FindFirstChild(v.Name).Material = Enum.Material[tostring(data23[2])]
  75. end
  76. end)
  77. end
  78. end
  79. end
  80. end)
  81. if data ~= nil then
  82. for i,v in pairs(data) do
  83. local cloneIt = false
  84. for a,b in pairs(script.Config:GetChildren()) do
  85. if b.Name == i then
  86. cloneIt = true
  87. end
  88. end
  89. if cloneIt == true then
  90. config[i].Value = v
  91. end
  92. end
  93. if Workspace.Houses:FindFirstChild(p.Name.."'s house") ~= nil then
  94. local house = Workspace.Houses:FindFirstChild(p.Name.."'s house")
  95. for i,v in pairs(data) do
  96. local cloneIt = false
  97. for a,b in pairs(script.Config:GetChildren()) do
  98. if b.Name == i then
  99. cloneIt = true
  100. end
  101. end
  102. if cloneIt == false then
  103. local data2 = {}
  104. for ii in string.gmatch(v, "%S+") do
  105. table.insert(data2,ii)
  106. end
  107. local name = ""
  108. for ii in string.gmatch(i, "%D+") do name = ii end
  109. local obj = game.ReplicatedStorage.Furniture[name]:Clone()
  110. obj.Parent = house
  111. obj.Name = i
  112. obj:TranslateBy((Vector3.new(tonumber(string.sub(data2[1],1,string.len(data2[1])-1)),tonumber(string.sub(data2[2],1,string.len(data2[2])-1)),tonumber(string.sub(data2[3],1,string.len(data2[3])-1)))+house.Base.Position)-obj:GetModelCFrame().p)
  113. --print(house.Base.Position,obj:GetModelCFrame().p)
  114. for ii,vv in pairs(obj:GetChildren()) do
  115. if not vv:IsA("IntValue") and not vv:IsA("StringValue") then
  116. vv.CFrame = (obj:GetModelCFrame()*CFrame.Angles(0,tonumber(data2[4]),0)):toWorldSpace(obj:GetModelCFrame():toObjectSpace(vv.CFrame))
  117. end
  118. end
  119. local save = Instance.new("StringValue")
  120. save.Value = tostring(obj:GetModelCFrame().p-house.Base.Position)..", "..data2[4]--tostring(obj:GetModelCFrame().p)..", "..data2[4]
  121. save.Name = i
  122. save.Parent = config
  123. end
  124. end
  125. end
  126. end
  127.  
  128. end)
  129.  
  130. Workspace.Houses.ChildAdded:connect(function(child)
  131. wait()
  132. game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
  133. child:WaitForChild("Locked").Changed:connect(function()
  134. wait()
  135. game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
  136. end)
  137. end)
  138.  
  139. Workspace.Houses.ChildRemoved:connect(function()
  140. wait()
  141. game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
  142. end)
  143.  
  144. game.Players.PlayerRemoving:connect(function(p)
  145. local Data={}
  146. for i,v in pairs(p.Config:GetChildren()) do--Saving
  147. Data[v.Name] = v.Value
  148. end
  149. local house = Workspace.Houses:FindFirstChild(p.Name.."'s house")
  150. if house ~= nil then
  151. house:Destroy()
  152. end
  153. stats:SetAsync(p.userId, Data)
  154. wait(1)
  155. game.ReplicatedStorage.UpdateLists.Value = not game.ReplicatedStorage.UpdateLists.Value
  156. end)
  157.  
  158. game.OnClose = function()
  159. wait(3)
  160. end
  161.  
  162. local event = Instance.new("RemoteFunction")
  163. event.Parent = Workspace
  164. event.Name = "ChangeValue"
  165. function event.OnServerInvoke(plr,name,newVal)
  166. plr.Config[name].Value = newVal
  167. return ""
  168. end
  169.  
  170. local event38 = Instance.new("RemoteEvent")
  171. event38.Parent = Workspace
  172. event38.Name = "Destroyer"
  173. event38.OnServerEvent:connect(function(plr,obj)
  174. obj:Destroy()
  175. end)
  176.  
  177. local event3 = Instance.new("RemoteEvent")
  178. event3.Parent = Workspace
  179. event3.Name = "AddFurniture"
  180. event3.OnServerEvent:connect(function(plr,house,furniture,pos,rotation)
  181. local obj = furniture:Clone()
  182. obj.Parent = house
  183. obj:TranslateBy(pos-obj:GetModelCFrame().p)
  184. for i,v in pairs(obj:GetChildren()) do
  185. if not v:IsA("IntValue") or v:IsA("StringValue") then
  186. v.CFrame = (obj:GetModelCFrame()*CFrame.Angles(0,rotation,0)):toWorldSpace(obj:GetModelCFrame():toObjectSpace(v.CFrame))
  187. end
  188. end
  189. local count = 1
  190. for i, v in pairs(plr.Config:GetChildren()) do
  191. if furniture.Name:find(v.Name:match("%D+")) and v.Name:match("%d+") then
  192. if count < tonumber(v.Name:match("%d+")) then
  193. count = tonumber(v.Name:match("%d+"))
  194. end
  195. end
  196. end
  197. count = count + 1
  198. local save = Instance.new("StringValue")
  199. save.Value = tostring(obj:GetModelCFrame().p-house.Base.Position)..", "..rotation
  200. save.Name = furniture.Name..count
  201. obj.Name = furniture.Name..count
  202. save.Parent = plr.Config
  203. end)
  204.  
  205. local event2 = Instance.new("RemoteFunction")
  206. event2.Parent = Workspace
  207. event2.Name = "LockHouse"
  208. function event2.OnServerInvoke(plr,house)
  209. house.Locked.Value = not house.Locked.Value
  210. return house.Locked.Value
  211. end
  212.  
  213. function SpawnVeza()
  214. Workspace.Vezas:ClearAllChildren()
  215. local PossibleLocations = {}
  216. for i,v in pairs(Workspace.VezaSpawns:GetChildren()) do
  217. table.insert(PossibleLocations,v)
  218. end
  219. local Num = math.floor(#PossibleLocations*ChancesOfFindingVeza)
  220. for i=1, Num do
  221. local pos = math.random(1,#PossibleLocations)
  222. local chosen = PossibleLocations[pos]
  223. local veza = nil
  224. if math.random(1,100) <= ChancesOfGettingRare then
  225. veza = game.ReplicatedStorage.Veza["Gold Rare Veza"]:Clone()
  226. else
  227. veza = game.ReplicatedStorage.Veza["Normal Veza"]:Clone()
  228. end
  229. veza.Parent = Workspace.Vezas
  230. veza.CFrame = chosen.CFrame
  231. table.remove(PossibleLocations, pos)
  232. end
  233. return
  234. end
  235.  
  236. local event332 = Instance.new("RemoteEvent")
  237. event332.Parent = Workspace
  238. event332.Name = "DetailedChange"
  239. event332.OnServerEvent:connect(function(plr,location,NAME, newVal)
  240. location[NAME] = newVal
  241. end)
  242.  
  243. SpawnVeza()
  244. while wait(RegenTime) do
  245. SpawnVeza()
  246. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement