[SOLVED] NPC Characters Not Unseating

Hello there,

I have NPCs in my game which walk around, sit, stand, and leave. Below, is the Unseat() function I made for making the NPCs stand. It works for the first ~6-8 NPCs, but then after that the NPCs Jump value is set to true, but they do not leave their seat. This results in the NPCs trying to walk in their seat. I’ve spent over a week, with hours each day, trying to figure this out and I can’t find a solution.

-- Unseats a character from a seat
function movement:Unseat(character)
	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")

	if animator then
		local sitAnimationTrack = animator:FindFirstChild("SitAnimationTrack")
		if sitAnimationTrack then
			sitAnimationTrack:Stop()
		end
	end
	
	--humanoid.Jump = true
	humanoid.Sit = false
	wait(0.1)
	humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end

Any help would me much appreciated. Thank you!

Fixed! Here is the updated code for those who may need it:

-- Unseats a character from a seat
function movement:Unseat(character)
	local humanoid = character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")
	local seat = humanoid.SeatPart

	if animator then
		local sitAnimationTrack = animator:FindFirstChild("SitAnimationTrack")
		if sitAnimationTrack then
			sitAnimationTrack:Stop()
		end
	end
	
	-- Updated code here
	if seat ~= nil then
		local weld = seat:FindFirstChildOfClass('Weld')
		if weld then
			humanoid.Sit = false
			weld:Destroy()
		end
	end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.