Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bed = script.Parent
- local billboard = bed:FindFirstChild("nameTagGui")
- local claimSeat = bed:FindFirstChild("ClaimSeat") -- seat part
- local function claimBed(player)
- if not ownerName then
- ownerName = player.Name
- player:SetAttribute("IsOnBed", true) -- set player is on bed to true
- claimSeat:Sit(player.Character.Humanoid)
- if billboard then
- billboard.nameLabel.Text = "(@"..ownerName..")"
- billboard.displayLabel.Text = player.DisplayName
- billboard.Enabled = true
- end
- end
- end
- local function releaseBed(player)
- if ownerName and ownerName == player.Name then
- ownerName = nil
- player:SetAttribute("IsOnBed", nil) -- set to nil if release bed
- if billboard then
- billboard.nameLabel.Text = ""
- billboard.displayLabel.Text = ""
- billboard.Enabled = false
- end
- end
- end
- bed.Blanket.ProximityPrompt.Triggered:Connect(function(player)
- if player then
- if not ownerName and not player:IsAncestorOf(bed) then
- claimBed(player)
- else
- releaseBed(player)
- 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.Name then
- claimSeat:Sit(player.Character.Humanoid)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment