Advertisement
Sungmingamerpro13

BedScript with NameLabelGui

Feb 11th, 2025
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.78 KB | None | 0 0
  1. local Bed = script.Parent
  2. local billboard = Bed:FindFirstChild("NameGui")
  3. local claimSeat = Bed:FindFirstChild("Seat") -- seat part
  4. local ownerName = nil
  5.  
  6. local function claimBed(player)
  7.     if not ownerName then
  8.         ownerName = player.Name
  9.         player:SetAttribute("IsOnBed", true) -- set player is on bed to true
  10.         if billboard then
  11.             billboard.nameLabel.Text = ownerName
  12.             billboard.Enabled = true
  13.         end
  14.     end
  15. end
  16.  
  17. claimSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
  18.     local Humanoid = claimSeat.Occupant
  19.     if not Humanoid then
  20.         return
  21.     end
  22.  
  23.     local Character = Humanoid.Parent
  24.     local player = game.Players:GetPlayerFromCharacter(Character)
  25.     if player then
  26.         if not ownerName and not player:GetAttribute("IsOnBed") then
  27.             claimBed(player)
  28.         end
  29.     end
  30. end)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement