Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- local PlayerScripts = Player:WaitForChild("PlayerScripts")
- local ReplicatedStorage = game.ReplicatedStorage
- local Remotes = ReplicatedStorage.Remotes
- local ModuleScripts = PlayerScripts:WaitForChild("ModuleScripts")
- local Housing = ReplicatedStorage.Housing
- _G.CurrentHouseName = "None"
- _G.CurrentHouseOwner = "None"
- local ModelCFrame = require(ModuleScripts.ModelCFrame)
- function LoadFurniture(HouseData)
- local House = workspace[HouseData.Name]
- local Interior = House.Interior
- local InteriorCFrame = Interior:GetModelCFrame()
- local FurnitureModel = workspace[HouseData.Name]:FindFirstChild("Furniture") or Instance.new("Model", workspace[HouseData.Name])
- FurnitureModel.Name = "Furniture"
- for PieceName, Piece in pairs(HouseData.Furniture) do
- if Piece and Piece.Positions then
- for _, Pos in pairs(Piece.Positions) do
- local Model = ReplicatedStorage.Housing.Furniture[PieceName]:Clone()
- local PieceCFrame = CFrame.new(unpack(Pos))
- local TransformToGlobalCFrame = InteriorCFrame * PieceCFrame
- Model.Parent = workspace[HouseData.Name].Furniture
- ModelCFrame.CFrame(Model, TransformToGlobalCFrame)
- end
- end
- end
- end
- function LoadDecorates(HouseData)
- local Interior = workspace[HouseData.Name].Interior
- for BaseName, Base in pairs(HouseData.Bases) do
- if Base.BrickColor and Interior:FindFirstChild(BaseName) then
- Interior[BaseName].BrickColor = BrickColor.new(Base.BrickColor)
- elseif Interior:FindFirstChild(BaseName) then
- --Interior[BaseName].BrickColor = BrickColor.new("Dark stone grey")
- end
- Interior[BaseName].Material = Base.Material or Enum.Material.Plastic
- end
- end
- function EnterHouse(NameOfHouse, Owner)
- if game.Teams:FindFirstChild("Prisoner") and game.Players.LocalPlayer.Team == game.Teams.Prisoner then
- ypcall(function()
- local gu = game.Players.LocalPlayer:FindFirstChild("NOTELEPORTGUIOK", true)
- if gu then
- gu.Parent.Visible = true
- wait(5)
- gu.Parent.Visible = false
- end
- end)
- return false
- elseif game.Teams:FindFirstChild("Hostage") and game.Players.LocalPlayer.Team == game.Teams.Hostage then
- ypcall(function()
- local gu = game.Players.LocalPlayer:FindFirstChild("NOTELEPORTGUIOK", true)
- if gu then
- gu.Parent.Visible = true
- wait(5)
- gu.Parent.Visible = false
- end
- end)
- return false
- end
- _G.CurrentHouseName = NameOfHouse
- _G.CurrentHouseOwner = Owner
- if not game.Players:FindFirstChild(_G.CurrentHouseOwner) then return end
- _G.InHouse = true
- local HouseData = game.ReplicatedStorage.Remotes.Functions.GetHouseByName:InvokeServer(Owner, NameOfHouse)
- if workspace[HouseData.Name]:FindFirstChild("Exterior") then
- workspace[HouseData.Name].Exterior.Parent = Housing
- end
- if workspace[HouseData.Name]:FindFirstChild("Interior") then
- workspace[HouseData.Name].Interior:Destroy()
- end
- local Interior = Housing["Interior Housing"][HouseData.Name]:GetChildren()[1]:Clone()
- local Position = Interior:GetModelCFrame()
- Interior.Parent = workspace[HouseData.Name]
- ModelCFrame.CFrame(Interior, Position)
- LoadDecorates(HouseData)
- LoadFurniture(HouseData)
- Player.Character.Torso.CFrame = Interior.Teleport.CFrame + Vector3.new(0, 3, 0)
- end
- _G.Leaving = false
- function LeaveHouse()
- _G.Leaving = true
- _G.Teleporting = true
- if _G.Placing then
- if _G.Selected and workspace:FindFirstChild(_G.Selected) then
- workspace[_G.Selected]:Destroy()
- end
- _G.Placing = false
- end
- if workspace[_G.CurrentHouseName]:FindFirstChild("Furniture") then
- workspace[_G.CurrentHouseName].Furniture:Destroy()
- end
- Remotes.Events.ExitHouse:FireServer(_G.CurrentHouseName, _G.CurrentHouseOwner)
- delay(1, function() _G.Teleporting = false end)
- if _G.InDecorateMode then
- game.ReplicatedStorage.Bindables.Client.Events.CloseDecorateMode:Fire()
- end
- _G.InHouse = false
- _G.InYourHouse = false
- coroutine.resume(coroutine.create(function()
- local st = tick()
- ypcall(function() repeat wait(0.01) until not _G.Selected_Furniture or _G.Selected_Furniture.Parent == nil end)
- _G.Leaving = false
- end))
- end
- ReplicatedStorage.Bindables.Client.Events.EnterHouse.Event:connect(function(HouseName, Owner)
- if not HouseName or HouseName == "None" or not Owner then return end
- EnterHouse(HouseName, Owner)
- end)
- ReplicatedStorage.Bindables.Client.Events.LeaveHouse.Event:connect(function()
- LeaveHouse()
- end)
- _G.Force_Exit_House = function()
- if _G.InHouse then
- LeaveHouse()
- game.ReplicatedStorage.Remotes.Events.RemoveHouse:FireServer(_G.CurrentHouseOwner)
- game.ReplicatedStorage.Bindables.Client.Events.LeaveHouse:Fire()
- local ct = tick() repeat wait(0.01) until (game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.Parent == game.Workspace) or (tick() - ct) >= 5
- wait(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement