Sungmingamerpro13

Bed System Styled Break In Story v2

Jan 29th, 2026
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.42 KB | None | 0 0
  1. local bed = script.Parent
  2. local billboard = bed:WaitForChild("nameTagGui")
  3. local claimSeat = bed:WaitForChild("ClaimSeat")
  4. local ownerValue = bed:WaitForChild("Owner")
  5.  
  6. local BedsFolder = workspace:WaitForChild("Beds")
  7.  
  8. local function releaseBed(bedModel)
  9.     local owner = bedModel:FindFirstChild("Owner")
  10.     if owner then
  11.         owner.Value = ""
  12.     end
  13.  
  14.     local board = bedModel:FindFirstChild("nameTagGui")
  15.     if board then
  16.         board.nameLabel.Text = ""
  17.     end
  18. end
  19.  
  20. local function playerHasBed(player)
  21.     for _, b in pairs(BedsFolder:GetChildren()) do
  22.         local owner = b:FindFirstChild("Owner")
  23.         if owner and owner.Value == player.Name then
  24.             return b
  25.         end
  26.     end
  27.     return nil
  28. end
  29.  
  30. claimSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
  31.     local humanoid = claimSeat.Occupant
  32.     if not humanoid then
  33.         return
  34.     end
  35.    
  36.     local Character = humanoid.Parent
  37.     local player = game.Players:GetPlayerFromCharacter(Character)
  38.     if player then
  39.         -- Check if player already owns a bed
  40.         local oldBed = playerHasBed(player)
  41.         if oldBed and oldBed ~= bed then
  42.             releaseBed(oldBed)
  43.         end
  44.  
  45.         if game:GetService("Lighting").TimeOfDay == "00:00:00" then
  46.             player.Character.Humanoid.Health += 10
  47.             game:GetService("Lighting").TimeOfDay = "14:30:00"
  48.         else
  49.             print("You Can Only Sleep at Night!")
  50.         end
  51.  
  52.         -- Claim this bed
  53.         ownerValue.Value = player.Name
  54.         billboard.nameLabel.Text = ownerValue.Value.." 's Bed"
  55.     end
  56. end)
  57.  
Advertisement
Add Comment
Please, Sign In to add comment