Why do the npcs do this?

So I have made a tds like game but im experiencing problems with npc lag or smt here is the footage:


I have set the ownership to nil but that didnt work.
Please help.

2 Likes

Can we see a video that isn’t cropped?

1 Like

alr here

2 Likes

This seems like a problem for #help-and-feedback:scripting-support. Once you move your post, can i see the script you’re using, or the block of code you use to move the NPC’s?

1 Like

I moved the tag and here is the part of the script that actually moves the npc

	for i = 1,#workspace.Waypoints:GetChildren() do
		repeat 
			wait(.2)
			waypointat.Value = i
			script.Parent.Humanoid:MoveTo(workspace.Waypoints[i - 1].Position) 
		until (Vector3.new(script.Parent.Humanoid.RootPart.Position.X,0,script.Parent.Humanoid.RootPart.Position.Z) - Vector3.new(workspace.Waypoints[i - 1].Position.X,0,workspace.Waypoints[i - 1].Position.Z)).magnitude < 1.5
	end

Im using “repeat” as some mobs have ability that stop them from moving for a little time and then continue.

Can you try MoveToFinished:Wait() instead of wait(.2)?


Still the same.

Hmm… I don’t know if i can help with this situation much. Have you checked to see if your ping and other performance-related numbers are higher than usual?

My ping is always around 45
Screenshot 2024-07-06 at 9.11.49 PM

1 Like

Also if it was a ping related problem wouldn’t all the noobs freeze / be slower or smt

1 Like

Increase the magnitude check from 1.5 to a higher value, and the wait may need to be decreased as well. If you are using path finding service, there are some attributes you can set to determine at what radius the current waypoint is ‘reached’.

Roblox default Humanoids are horribly optimized and will lag the game if you have a lot. There’s a few things you can do to try to optimize them like disable states that will never be used such as climbing, swimming, etc. It explains it better here: How to Optimize Humanoids

Edit: After checking out the video again it actually seems more like a script related issue than a performance issue.

Change the script to something like this:

	for i = 1,#workspace.Waypoints:GetChildren() do
        script.Parent.Humanoid:MoveTo(workspace.Waypoints[i - 1].Position)
        script.Parent.Humanoid.MoveToFinished:Wait()
	end

Like I said some noobs have abilitys that prevent them from walking for a couple seconds so movetofinish wont work.

By the way I noticed that this only happens in one spot and not anywhere else.