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

Why does my humanoid trip after unanchoring?

Asked by 2 years ago

Greetings. I'm currently working with my brother on a game that is based on another game that we are both fans of. I'm not going to go into detail on what it is or what it's based on, I'll just tell you what my problem is.

The Problem: My NPC is a regular R6 rig with a custom rig attached to the root part. (I have never made a custom humanoid rig, so this was most convenient for me.) The server script is located inside of the NPC. The NPC is supposed to chase the player around hallways, however, the player can enter rooms that have hiding spots.

If the player was caught entering the room, the NPC will enter the room which the player is in, and if the player was not in a hiding spot, they will die. This goes as so:

  1. NPC's root part is anchored
  2. NPC's CFrame is set to a specific spot in front of the entrance to the room
  3. An animation of the NPC entering and leaving the room will play
  4. The Player will be killed or left alive
  5. NPC's root part is unanchored, and the animation will stop. This is where my problem is.

The first time the NPC enters the room, everything is fine. The NPC's root is unanchored and everything is fine. Usually, that would be the case, however, my findings have shown this to be inconsistent.

The second/first time that the NPC would enter a room, however, is where the problem would occur.

All of my problems are occurring in the Roblox Client, not Roblox Studio. This is only because I do not own the game and in order to see the animations, I have to go into the game myself. The NPC shown walking in place inside the GIF is unrelated, and I do not need any assistance regarding that problem.

Here's my code. (Since the Lua Code block does not seem to be properly showing my code, I have decided to send it here via a screenshot. I hope you understand.)

What I have tried: I tried changing the WalkSpeed instead of the Anchored property, but it seems to cause another problem that I'm unsure how to solve. I also tried changing the state of the NPC's Humanoid to GettingUp after unanchoring. According to Roblox DevForum, this seemed to work, but for me, it did not.

I tried a lot of other solutions that other people have come up with, but, you wouldn't be reading this if that worked.

Conclusion: Sorry if my code's a bit messy, I wouldn't call myself a beginner, but I wouldn't call myself good at scripting either.

That's all I have to say at the moment. If any information is missing, leave a comment and I'll update my question with the new info. Thanks for taking the time to read my question. (repost because nobody answered my question)

Answer this question