Sleep Script: attempt to index boolean with 'Jumping'

-- SERVICES --
local UserInputService = game:GetService("UserInputService")


-- CONSTANTS --
local part = script.Parent

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://10214821046"

-- VARIABLES --
local sleep = false
local Character
local Humanoid = false
local Animator
local HumanoidRootPart
local Track

local function onPartTouched(otherPart)

	Humanoid = otherPart.Parent:FindFirstChildWhichIsA("Humanoid")
	if Humanoid then
		local Track = Animator:LoadAnimation(animation)
		Track.Priority = Enum.AnimationPriority.Action
		Track.Looped = true

		Character = Humanoid.Parent
		HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
		Animator = Humanoid:WaitForChild("Animator")

		HumanoidRootPart.Anchored = true
		HumanoidRootPart.CFrame = CFrame.new(Vector3.new(part.Position.X, part.Position.Y+4, part.Position.Z)) * CFrame.Angles(0, part.Orientation.Y, 0)
		Track:Play()
		
		Humanoid.Jumping:Connect(function(IsJumping)
			if IsJumping then
				HumanoidRootPart.Anchored = false -- LINE 37
				Track:Stop()
				Humanoid = false
			end
		end)
	end
end

part.Touched:Connect(onPartTouched)```

This script is supposed to be checking if a player touches the bed (script.Parent) and if they are, it anchors them and plays a sleeping animation. It also puts them on the bed. And, when that person jumps, it unanchors and stops the animation.

Your Humanoid.Jumping is still connected even though you set humanoid inside the connection to Humanoid = false. Make a local variable to track the script connection like so

local jumpingConnection -- must be declared before connection, since
-- we are going to use this inside the function to disconnect.
jumpingConnection = Humanoid.Jumping:Connect(function(IsJumping)
	if IsJumping then
		HumanoidRootPart.Anchored = false -- LINE 37
		Track:Stop()
		Humanoid = false
		jumpingConnection:Disconnect()
	end
end)

hmm. it lets me sleep, but i cant wake up by jumping anymore.

-- SERVICES --
local UserInputService = game:GetService("UserInputService")


-- CONSTANTS --
local part = script.Parent

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://10214821046"

-- VARIABLES --
local sleep = false
local Character
local Humanoid = false
local Animator
local HumanoidRootPart
local Track

local jumpingConnection

local function onPartTouched(otherPart)
	Humanoid = otherPart.Parent:FindFirstChildWhichIsA("Humanoid")
	if Humanoid then
		Character = Humanoid.Parent
		HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
		Animator = Humanoid:WaitForChild("Animator")

		Track = Animator:LoadAnimation(animation)
		Track.Priority = Enum.AnimationPriority.Action
		Track.Looped = true

		HumanoidRootPart.Anchored = true
		HumanoidRootPart.CFrame = CFrame.new(Vector3.new(part.Position.X, part.Position.Y+4, part.Position.Z)) * CFrame.Angles(0, part.Orientation.Y, 0)
		Track:Play()

		jumpingConnection = Humanoid.Jumping:Connect(function(IsJumping)
			if IsJumping then
				HumanoidRootPart.Anchored = false
				Track:Stop()
				Humanoid = false
				jumpingConnection:Disconnect()
			end
		end)
	end
end

part.Touched:Connect(onPartTouched)