Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local BedPlotHandler = {}
- BedPlotHandler.AvaliablePlots = game.Workspace.Beds:GetChildren()
- function BedPlotHandler.GetBed(player)
- for _, bedPlot in pairs(game.Workspace.Beds:GetChildren()) do
- local ownerValue = bedPlot:FindFirstChild("Owner")
- if ownerValue and ownerValue.Value == player then
- return bedPlot
- end
- end
- end
- local function UpdateBedGui(plot, Text)
- local OwnernameTag = plot:FindFirstChild("nameTagGui")
- OwnernameTag.nameLabel.Text = Text.."'s Bed"
- end
- function BedPlotHandler.namePlot(player)
- local playerPlot = BedPlotHandler.AvaliablePlots[math.random(1,#BedPlotHandler.AvaliablePlots)]
- table.remove(BedPlotHandler.AvaliablePlots, table.find(BedPlotHandler.AvaliablePlots, playerPlot))
- local ownerValue = playerPlot:FindFirstChild("Owner") or Instance.new("ObjectValue")
- ownerValue.Name = "Owner"
- ownerValue.Parent = playerPlot
- ownerValue.Value = player
- UpdateBedGui(playerPlot, player.DisplayName)
- end
- function BedPlotHandler.NoNamePlot(player)
- local bedPlot = BedPlotHandler.GetBed(player)
- if bedPlot then
- bedPlot:FindFirstChild("Owner").Value = nil
- table.insert(BedPlotHandler.AvaliablePlots, bedPlot)
- UpdateBedGui(bedPlot, "PlayerName")
- end
- end
- return BedPlotHandler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement