local Bed = script.Parent
local billboard = Bed:FindFirstChild("NameGui")
local claimSeat = Bed:FindFirstChild("Seat") -- seat part
local ownerName = nil
local function claimBed(player)
if not ownerName then
ownerName = player.Name
player:SetAttribute("IsOnBed", true) -- set player is on bed to true
if billboard then
billboard.nameLabel.Text = ownerName
billboard.Enabled = true
end
end
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
if not ownerName and not player:GetAttribute("IsOnBed") then
claimBed(player)
end
end
end)