Pathfinding | Tweening NPC's speed is not linear

There are many ways to make anti-cheat.
Also, the client script can’t really be hacked unless you’re using remote events. It’s not like they can jump into the code and change the lines.

I tried this, and it seems mostly functional! However, even though the brick is anchored, when you die, it starts flying into the void and disappears. Any thoughts?

1 Like

Check if the players dead and stop pathfinding if so.

my guess is you died and its chasing your humanoidrootpart (which is probably falling into the void)

1 Like

I was planning on using remote events to update brick’s position on the serverside because the game is multiplayer. Exploiters could manipulate it there

1 Like

Fair, I was just giving you a quick break-down on why this issue was present lol, best of luck to your game

1 Like
if distance <= closestDistance and distance and v.Character:FindFirstChildOfClass("Humanoid") and v.Character:FindFirstChildOfClass("Humanoid").Health > 0 then -- if the distance of the player is smaller than the previous closest distance, then run the code below

(making sure dead players arent checked)

2 Likes

I’ve tried this, but for some reason it’s defunctional. I don’t exactly know why, either.

1 Like

It is working as expected now. Thank you very much for your help, the brick now kills you if you are running in a straight line! You deserve a gold star for your efforts!

2 Likes

if it isnt taking dead players as new variables, the issue is probably in the following script; in which you can do

for z,waypoint in pairs(path:GetWaypoints()) do -- get all of the waypoints
if closestPlayer.Parent:FindFirstChildOfClass("Humanoid").Health <= 0 then return end
			local newerPos = waypoint.Position
		 
			local bestTween = ts:Create(script.Parent, info, {Position = newerPos})

			bestTween:Play()

		task.wait(math.clamp(brickSpeed, 0.05, 2)/closestDistance)

edit; nvm

2 Likes

Sorry, I accidentally put the if statement in the wrong place which is why it was causing the issue. I corrected it, and it works as expected now.

1 Like

Its already been solved Bro :sob::sob:

1 Like

The brick has no humanoid. I recommend reading through the replies first before posting.

1 Like