humanoid:Sit() forcing npc to sit forever?

I have made a tycoon NPC which if they work to they limit (which is a energy number value) it will jump of the chair and walk to the vending machine. However, the script worked, it jumping off, but the problem is about jumping! (i guess) the NPC jumping script is a serverside script but it behaved to jump off with a client script, the vending machine placement was a modulescript with a serverside (because you can see a machine in a serverside) but the npc act like it was a client side! is this a bug? or is my script error?

Video: (problem part)

Video: (full part)

NOTE: this is the moving script which will be cloned to the NPC when it was first finish the drinking script
Script in a NPC:

> local chair = script:WaitForChild("Chair").Value
> local dapath = game:GetService("PathfindingService"):CreatePath()
> while wait(math.random(1,2)) do
> 	print("Staring...")
> 	if script.Cooldown.Value == true then
> 		print("Checking.......")
> 		if script.Parent.Humanoid.SeatPart then
> 			for i,v in pairs(game.Players:GetChildren()) do
> 				if v.UserId == script.Parent.Owner.Value then
> 					if script.Energy.Value < 0 or script.Energy.Value == 0 then
> 						script.Cooldown.Value = false
> 						--NEED TO REST
> 						print("Going to resting...")
> 						for i,v in pairs(game.Workspace.PlotDetails:GetChildren()) do
> 							if v.Name == "VendingMachine" and v:FindFirstChild("Owner") and v:FindFirstChild("Owner").Value == script.Parent.Owner.Value then
> 								local npcwalkpos = v:FindFirstChild("NPCWalkPos")
> 								if npcwalkpos then
> 									script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
> 									dapath:ComputeAsync(script.Parent.PrimaryPart.Position,npcwalkpos.Position)
> 									local point = dapath:GetWaypoints()
> 									for i,way in pairs(point) do
> 										if way.Action == Enum.PathWaypointAction.Jump then
> 											script.Parent.Humanoid.Jump = true
> 										end
> 										script.Parent.Humanoid:MoveTo(way.Position)
> 										script.Parent.Humanoid.MoveToFinished:Wait()
> 									end
> 									wait(2)
> 									local bloxy = game.ReplicatedStorage.BloxyCola:Clone()
> 									bloxy.Parent = script.Parent
> 									while wait(math.random(0.1,0.2)) do
> 										local drinking = bloxy.DrinkSound:Clone()
> 										drinking.Parent = script.Parent:FindFirstChild("Head")
> 										drinking.PlayOnRemove = true
> 										drinking:Destroy()
> 										if bloxy.Handle.Energy.Value <= 0 then
> 											bloxy:Destroy()
> 											script.Energy.Value = 1
> 											break
> 										else
> 											bloxy.Handle.Energy.Value = bloxy.Handle.Energy.Value - (math.random(5,10)* 2)
> 										end 
> 									end
> 									--GOING BACK TO WORK
> 									dapath:ComputeAsync(script.Parent.PrimaryPart.Position,chair.Position)
> 									local way = dapath:GetWaypoints()
> 									for i,point in pairs(way) do
> 										if point.Action == Enum.PathWaypointAction.Jump then
> 											script.Parent.Humanoid.Jump = true
> 										end
> 										script.Parent.Humanoid:MoveTo(point.Position)
> 										script.Parent.Humanoid.MoveToFinished:Wait()
> 									end
> 									--GG GAMING
> 									repeat
> 										print("Still finding a chair")
> 										local daway = chair:Sit(script.Parent.Humanoid)
> 										if script.Parent.Humanoid.SeatPart.Parent:FindFirstChild("Owner").Value == script.Parent.Owner.Value then
> 											break
> 										end
> 										wait()
> 									until false
> 									script.Cooldown.Value = true
> 									local dawaa = game.Lighting.ProgrammerRestScript:Clone()
> 									dawaa.Parent = script.Parent
> 									dawaa.Chair.Value = chair
> 									dawaa.Disabled = false
> 									script:Destroy()
> 								end
> 							end
> 						end
> 					elseif script.Energy.Value > 0 then
> 						print("Decreasing")
> 						print("More WORK!!")
> 						script.Energy.Value = script.Energy.Value - (math.random(5,20)*5)
> 						v.Coins.Value = v.Coins.Value + (10 * v.TreasureRate.Value)
> 						v.XP.Value = v.XP.Value +(math.random(1,20) * v.TreasureRate.Value) 
> 					end
> 				end
> 			end
> 		end
> 	end
> end 

I can give you more information if you did ask me! But it need to be irrevant with the problems!


I’d suggest using

script.Parent.Humanoid.Jump = true

try it and see if it solves your problem

1 Like

i used both of them to do it, but still it not working ;-;

1 Like

It seems to be an issue with the animations, have you checked the state of the npc after it gets out of the desk?
Edit : try script.Parent.Humanoid.Sit = false

i think it’s no a problem about an animation, because i tried checking on the table and printing about a seatpart and a occupant, we can see that the humanoid is jumping out, but the output seems that the humanoid is still seating there.
Sorry for the full vid
idk what just happen to it.

Try deleting the SeatWeld, it should be located in the seat itself

i get the descendant of a chair and destroy alll welds, but it didnt work
NOTE: i mixed all possible way together
line1 set a npc sitting to false
line2 set a npc jump to true
line3 deleting welds
and more
or should i delete all of them and add only a weld deletion?

1 Like

You should keep the jump value and the weld deletion

i update some forcing sit because i think it might be a problem:

			print("Still finding a chair")
			if script.Parent.Humanoid.SeatPart and script.Parent.Humanoid.SeatPart.Parent:FindFirstChild("Owner").Value == script.Parent.Owner.Value then
				print("Forcing player to sit")
		until false

and yes still didnt work

I’m gonna make a blind guess: Try setting the seat’s occupant to nil. Also it seems like the NPC is not in the sitting state, but rather just playing the sitting animation. One more thing is that:

I’m pretty sure changestate only works on client. I might be wrong.

ok! i’ll try deleting that part!

some time it work but sometime it doesnt!

isn’t the occupant a locked value, that is read-only?

That’s kind of why I said this.

perhaps you can try detecting the npc sitting, and instantly make it jump

1 Like

I assume that the seat is still colliding with the npc after it jumps and, therefore he sits back

1 Like

i already did the detection in the chair, but i dont know why it jump like it was fired in the client

if it is, then what should i do?

make sure the seat part isn’t too big

1 Like

i already check in my seat part
the size of it is: 1.578, 0.158, 1.578
i sure that isnt big!

Maybe do this:

NPC.SeatPart = -- whatever seat part

-- do something 

NPC.SeatPart = nil