Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. local Player = game.Players.LocalPlayer
  2.  
  3. local PlayerScripts = Player:WaitForChild("PlayerScripts")
  4. local ReplicatedStorage = game.ReplicatedStorage
  5. local Remotes = ReplicatedStorage.Remotes
  6. local ModuleScripts = PlayerScripts:WaitForChild("ModuleScripts")
  7.  
  8. local Housing = ReplicatedStorage.Housing
  9.  
  10. _G.CurrentHouseName = "None"
  11. _G.CurrentHouseOwner = "None"
  12.  
  13. local ModelCFrame = require(ModuleScripts.ModelCFrame)
  14.  
  15. function LoadFurniture(HouseData)
  16. local House = workspace[HouseData.Name]
  17. local Interior = House.Interior
  18. local InteriorCFrame = Interior:GetModelCFrame()
  19.  
  20. local FurnitureModel = workspace[HouseData.Name]:FindFirstChild("Furniture") or Instance.new("Model", workspace[HouseData.Name])
  21. FurnitureModel.Name = "Furniture"
  22.  
  23. for PieceName, Piece in pairs(HouseData.Furniture) do
  24. if Piece and Piece.Positions then
  25. for _, Pos in pairs(Piece.Positions) do
  26. local Model = ReplicatedStorage.Housing.Furniture[PieceName]:Clone()
  27. local PieceCFrame = CFrame.new(unpack(Pos))
  28. local TransformToGlobalCFrame = InteriorCFrame * PieceCFrame
  29. Model.Parent = workspace[HouseData.Name].Furniture
  30. ModelCFrame.CFrame(Model, TransformToGlobalCFrame)
  31. end
  32. end
  33. end
  34. end
  35.  
  36. function LoadDecorates(HouseData)
  37. local Interior = workspace[HouseData.Name].Interior
  38.  
  39. for BaseName, Base in pairs(HouseData.Bases) do
  40. if Base.BrickColor and Interior:FindFirstChild(BaseName) then
  41. Interior[BaseName].BrickColor = BrickColor.new(Base.BrickColor)
  42. elseif Interior:FindFirstChild(BaseName) then
  43. --Interior[BaseName].BrickColor = BrickColor.new("Dark stone grey")
  44. end
  45.  
  46. Interior[BaseName].Material = Base.Material or Enum.Material.Plastic
  47. end
  48. end
  49.  
  50. function EnterHouse(NameOfHouse, Owner)
  51. if game.Teams:FindFirstChild("Prisoner") and game.Players.LocalPlayer.Team == game.Teams.Prisoner then
  52. ypcall(function()
  53. local gu = game.Players.LocalPlayer:FindFirstChild("NOTELEPORTGUIOK", true)
  54. if gu then
  55. gu.Parent.Visible = true
  56. wait(5)
  57. gu.Parent.Visible = false
  58. end
  59. end)
  60. return false
  61. elseif game.Teams:FindFirstChild("Hostage") and game.Players.LocalPlayer.Team == game.Teams.Hostage then
  62. ypcall(function()
  63. local gu = game.Players.LocalPlayer:FindFirstChild("NOTELEPORTGUIOK", true)
  64. if gu then
  65. gu.Parent.Visible = true
  66. wait(5)
  67. gu.Parent.Visible = false
  68. end
  69. end)
  70. return false
  71. end
  72. _G.CurrentHouseName = NameOfHouse
  73. _G.CurrentHouseOwner = Owner
  74. if not game.Players:FindFirstChild(_G.CurrentHouseOwner) then return end
  75. _G.InHouse = true
  76. local HouseData = game.ReplicatedStorage.Remotes.Functions.GetHouseByName:InvokeServer(Owner, NameOfHouse)
  77.  
  78. if workspace[HouseData.Name]:FindFirstChild("Exterior") then
  79. workspace[HouseData.Name].Exterior.Parent = Housing
  80. end
  81.  
  82. if workspace[HouseData.Name]:FindFirstChild("Interior") then
  83. workspace[HouseData.Name].Interior:Destroy()
  84. end
  85.  
  86. local Interior = Housing["Interior Housing"][HouseData.Name]:GetChildren()[1]:Clone()
  87. local Position = Interior:GetModelCFrame()
  88. Interior.Parent = workspace[HouseData.Name]
  89.  
  90. ModelCFrame.CFrame(Interior, Position)
  91.  
  92. LoadDecorates(HouseData)
  93. LoadFurniture(HouseData)
  94. Player.Character.Torso.CFrame = Interior.Teleport.CFrame + Vector3.new(0, 3, 0)
  95. end
  96.  
  97. _G.Leaving = false
  98.  
  99. function LeaveHouse()
  100. _G.Leaving = true
  101. _G.Teleporting = true
  102. if _G.Placing then
  103. if _G.Selected and workspace:FindFirstChild(_G.Selected) then
  104. workspace[_G.Selected]:Destroy()
  105. end
  106. _G.Placing = false
  107. end
  108. if workspace[_G.CurrentHouseName]:FindFirstChild("Furniture") then
  109. workspace[_G.CurrentHouseName].Furniture:Destroy()
  110. end
  111.  
  112. Remotes.Events.ExitHouse:FireServer(_G.CurrentHouseName, _G.CurrentHouseOwner)
  113. delay(1, function() _G.Teleporting = false end)
  114.  
  115. if _G.InDecorateMode then
  116. game.ReplicatedStorage.Bindables.Client.Events.CloseDecorateMode:Fire()
  117. end
  118. _G.InHouse = false
  119. _G.InYourHouse = false
  120. coroutine.resume(coroutine.create(function()
  121. local st = tick()
  122. ypcall(function() repeat wait(0.01) until not _G.Selected_Furniture or _G.Selected_Furniture.Parent == nil end)
  123. _G.Leaving = false
  124. end))
  125. end
  126.  
  127. ReplicatedStorage.Bindables.Client.Events.EnterHouse.Event:connect(function(HouseName, Owner)
  128. if not HouseName or HouseName == "None" or not Owner then return end
  129. EnterHouse(HouseName, Owner)
  130. end)
  131.  
  132. ReplicatedStorage.Bindables.Client.Events.LeaveHouse.Event:connect(function()
  133. LeaveHouse()
  134. end)
  135.  
  136. _G.Force_Exit_House = function()
  137. if _G.InHouse then
  138. LeaveHouse()
  139. game.ReplicatedStorage.Remotes.Events.RemoveHouse:FireServer(_G.CurrentHouseOwner)
  140. game.ReplicatedStorage.Bindables.Client.Events.LeaveHouse:Fire()
  141. local ct = tick() repeat wait(0.01) until (game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.Parent == game.Workspace) or (tick() - ct) >= 5
  142. wait(1)
  143. end
  144. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement