Sungmingamerpro13

New Bed System Styled Break In (Script)

Aug 7th, 2025
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.34 KB | None | 0 0
  1. local bed = script.Parent
  2. local billboard = bed:FindFirstChild("nameTagGui")
  3. local claimSeat = bed:FindFirstChild("ClaimSeat") -- seat part
  4.  
  5. local function claimBed(player)
  6.     if not ownerName then
  7.         ownerName = player.Name
  8.         player:SetAttribute("IsOnBed", true) -- set player is on bed to true
  9.         claimSeat:Sit(player.Character.Humanoid)
  10.         if billboard then
  11.             billboard.nameLabel.Text = "(@"..ownerName..")"
  12.             billboard.displayLabel.Text = player.DisplayName
  13.             billboard.Enabled = true
  14.         end
  15.     end
  16. end
  17.  
  18. local function releaseBed(player)
  19.     if ownerName and ownerName == player.Name then
  20.         ownerName = nil
  21.         player:SetAttribute("IsOnBed", nil) -- set to nil if release bed
  22.         if billboard then
  23.             billboard.nameLabel.Text = ""
  24.             billboard.displayLabel.Text = ""
  25.             billboard.Enabled = false
  26.         end
  27.     end
  28. end
  29.  
  30. bed.Blanket.ProximityPrompt.Triggered:Connect(function(player)
  31.     if player then
  32.         if not ownerName and not player:IsAncestorOf(bed) then
  33.             claimBed(player)
  34.         else
  35.             releaseBed(player)
  36.         end
  37.     end
  38. end)
  39.  
  40. claimSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
  41.     local Humanoid = claimSeat.Occupant
  42.     if not Humanoid then
  43.         return
  44.     end
  45.  
  46.     local Character = Humanoid.Parent
  47.     local player = game.Players:GetPlayerFromCharacter(Character)
  48.    
  49.     if player.Name then
  50.         claimSeat:Sit(player.Character.Humanoid)
  51.     end
  52. end)
  53.  
Advertisement
Add Comment
Please, Sign In to add comment