Sungmingamerpro13

Bed System styled Break In Story

Jan 29th, 2026
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.27 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.Touched:Connect(function(hit)
  31.     local Character = hit.Parent
  32.     local player = game.Players:GetPlayerFromCharacter(Character)
  33.     -- Check if player already owns a bed
  34.     local oldBed = playerHasBed(player)
  35.     if oldBed and oldBed ~= bed then
  36.         releaseBed(oldBed)
  37.     end
  38.    
  39.     if game:GetService("Lighting").TimeOfDay == "00:00:00" then
  40.         player.Character.Humanoid.Health += 10
  41.         game:GetService("Lighting").TimeOfDay = "14:30:00"
  42.     else
  43.         print("You Can Only Sleep at Night!")
  44.     end
  45.  
  46.     -- Claim this bed
  47.     ownerValue.Value = player.Name
  48.     billboard.nameLabel.Text = ownerValue.Value.." 's Bed"
  49. end)
  50.  
Advertisement
Add Comment
Please, Sign In to add comment