-
What do you want to achieve?
I made a sleeping script that makes it so that when the proximity prompt is activated, the player sits on any unused seat in the tent and it plays a sleeping animation. -
What is the issue?
It works pretty well except when you try and sleep with a tool equipped, the animation breaks. I checked and this happened with every tool. Sometimes it fixes itself by chance but it doesn’t happen every time and I still don’t know why it happens. -
What solutions have you tried so far?
I tried usingTool:UnequipTools()but it only made the tool disappear and not the bug.
Expectation:

When a tool is equipped while sitting:

Here’s the entire script for it
local tent = script.Parent
local proximityPrompt = tent.Floor.Attachment.ProximityPrompt
proximityPrompt.Triggered:Connect(function(player)
-- make the player sit on an unused sleeping back and play the animation
for i, sb in ipairs(tent:GetChildren()) do
if string.match(sb.Name, "SleepingBag") then
if not sb.Seat.Occupant then
player.Character.Humanoid:UnequipTools()
sb.Seat:Sit(player.Character.Humanoid)
wait(0.2)
local anim = player.Character.Humanoid:LoadAnimation(script.SleepAnimation)
anim.Looped = true
anim:Play()
coroutine.resume(coroutine.create(function()
sb.Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
anim:Stop()
tent.Sleeping.Value = false
end)
end))
break
end
end
end
-- if everyone's sleeping
local a = 0
for i, char in pairs(workspace:GetChildren()) do
if game.Players:GetPlayerFromCharacter(char) and char:FindFirstChild("Humanoid") then
if string.match(char.Humanoid.SeatPart.Parent.Name, "SleepingBag") then
a += 1
end
end
end
if a == #game.Players:GetPlayers() then
tent.Sleeping.Value = true
end
end)