Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I prevent an NPC from always tripping?

Asked by
yoyyo75 74
4 years ago
Edited 4 years ago

I tried to search as much about it as I can but each time I clone an NPC (r15) from replicated storage it keeps tripping (falling dawn on spawn).

clone = game:GetService("ReplicatedStorage").Noob:Clone()
clone.Animate.Disabled = false
clone.Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
clone.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
clone.HumanoidRootPart.Anchored = false
clone.Parent = workspace
clone.HumanoidRootPart:SetNetworkOwner(nil)
clone:MoveTo(workspace.pad.Position)

Does anyone have any advise to prevent this? it has a basic animation playing on loop btw but I don't think that should matter

I just want my npc to spawn standing without falling down but this script wont work ._.

Edit: HumanoidRootPart gets anchored before placed to workspace

Ok so another thing is I forgot there is a part on top of the pad, but its cancollide = false. So when I use the MoveTo, it moves the NPC a very tiny bit higher (like < 1 on the y axis) because of the thing on top of the pad and once it gets unanchored it falls down.

When I use SetPrimaryPartCFrame, it sets the NPC half way below the pad. It will get up but still trip anyway

Ok.... So I made the thing on top of the pad a local part but they are still tripping lmao

How do I prevent this?

0
Have you tried doing the SetStateEnabled counter measures after putting it in workspace or after moving it to pad? LucarioZombie 291 — 4y
0
Yeah still tripping :( yoyyo75 74 — 4y
0
Try connecting a Humanoid.StateChanged to a function that checks if the changed state is falling/tripping, and if so, correct it with Humanoid:ChangeState() LucarioZombie 291 — 4y
0
That would create a stack-overflow like issue, **Change**State() will fire StateChanged but its event listener calls ChangeState so it keeps going like a recursive function programmerHere 371 — 4y
0
I would also like to spawn a lot of these, so Im assuming that might cause performance to be slower. Is there another way? yoyyo75 74 — 4y

Answer this question