Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bed = script.Parent
- local billboard = bed:WaitForChild("nameTagGui")
- local claimSeat = bed:WaitForChild("ClaimSeat")
- local ownerValue = bed:WaitForChild("Owner")
- local BedsFolder = workspace:WaitForChild("Beds")
- local function releaseBed(bedModel)
- local owner = bedModel:FindFirstChild("Owner")
- if owner then
- owner.Value = ""
- end
- local board = bedModel:FindFirstChild("nameTagGui")
- if board then
- board.nameLabel.Text = ""
- end
- end
- local function playerHasBed(player)
- for _, b in pairs(BedsFolder:GetChildren()) do
- local owner = b:FindFirstChild("Owner")
- if owner and owner.Value == player.Name then
- return b
- end
- end
- return nil
- end
- claimSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
- local humanoid = claimSeat.Occupant
- if not humanoid then
- return
- end
- local Character = humanoid.Parent
- local player = game.Players:GetPlayerFromCharacter(Character)
- if player then
- -- Check if player already owns a bed
- local oldBed = playerHasBed(player)
- if oldBed and oldBed ~= bed then
- releaseBed(oldBed)
- end
- if game:GetService("Lighting").TimeOfDay == "00:00:00" then
- player.Character.Humanoid.Health += 10
- game:GetService("Lighting").TimeOfDay = "14:30:00"
- else
- print("You Can Only Sleep at Night!")
- end
- -- Claim this bed
- ownerValue.Value = player.Name
- billboard.nameLabel.Text = ownerValue.Value.." 's Bed"
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment