Sit Animation Breaks when a Tool is Equipped

  1. 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.

  2. 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.

  3. What solutions have you tried so far?
    I tried using Tool:UnequipTools() but it only made the tool disappear and not the bug.

Expectation:
image

When a tool is equipped while sitting:
image

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)


Instead of using a seat, I’d pivot the player to the desired bed and then anchor their HumanoidRootPart there. You could ContextActionService bind to the space key or use a Gui button to have the player “wake up.” Another fix could be taking the player’s tools away while they are sleeping and giving them back afterwards.

1 Like

If disabling AnimationWeightedBlendFix a property in Workspace, fixes the issue, then contact @bug-support since that would be a bug.

2 Likes

I did not know animations could play even when the HumanoidRootPart is anchored; that’s pretty nice! But apparently, the problem was the AnimationWeightedBlendFix property being set to true according to @SubtotalAnt8185. Thanks for helping though!

Should I keep the property enabled and report it or should I keep it disabled for the sake of fixing my issue?

You need to report it. It will be enabled for all experiences on November 1st, so you should probably report a bug about it. I don’t support the AnimationWeightedBlendFix update at all.

Alright. I’ll see what I can do.