NPC don't move if told so on client

Hi,

So server creates NPC in script. Then on client i want to move this NPC, but the thing is that it will take a couple of seconds to start moving NPC. I’m 100% sure its not my scripts fault as i tested it and when i do Humanoid:MoveTo() it prints, but NPC don’t move.

So i guess this is problem with Server <-> Client replication.

Example:
https://gyazo.com/7c9936c60e35c45fd5653d5d09c3d0de

The Solution i found is that i can simply create NPC on Client and not Server.

Is there any way i can fix this besides creting NPC on Client and not Server? If no then i will just re-script NPC spawning function to work on Client :pensive:

1 Like

Well, i guess i will just re-script it to work on Client.

I really don’t want to do it, so if anyone have other ideas let me know!

You could probably try and use BasePart:SetNetworkOwner(player) on the npc’s rootpart and try again
(note: you can only use that in the server)

why create an npc on the server then move it on the client? AFAIK that change won’t replicate to the server

Well… When i made it i thought that i can create NPC on server and move it on server too, but then i noticed that its not smooth. So i decided to remade it so NPC will move on client and then FireServer to let server know player touched that, but heres the problem i got…

The thing about that server won’t see changes really don’t matter, i just create NPC there so they will appear for every player

1 Like

Well, this solution will require to server loop through all players and i try to avoid that…

I will probably just go ahead and make NPC creation function on Client, so there won’t be any problems with replication.

How are you moving the npc? Using pathfinding service always results in smooth npc movement for me

i just do NPC.Humanoid:MoveTo(PlayersCharacter.Humanoid.RootPart.Position)

what do you mean by not smooth exactly? I don’t see why there would be any issues with a humanoid moving like that. Have you tried using the command bar to see if it looks smooth then? in case it does it would be an issue with your script most likely

Well my bad. It is smooth, but NPC will start moving a bit later and not instantly when i enter a specific ‘zone’

Example: https://gyazo.com/7c9936c60e35c45fd5653d5d09c3d0de

I enter zone and i need to wait a couple of seconds and then NPC will start moving. After that if i re-enter the ‘zone’ it will start moving instantly

are you using Zone+ V2? or your own zones

I use my own system to check if player inside zone

I would suggest then using Zone+ V2. It’s super easy to set up and is very versatile and detects players entering zone instantly.

At the very least test your script using them, to see if your script is the issue or the problem is something else

There no problem with my zone system as i tried printing when player enters zone and it printed. Then i tried to add print near Humanoid:MoveTo and it printed too. So there no issue with my code.

well if you are creating an npc on the server, and moving it on the server then the only cause for the delay could be the script itself. There is no replication delay when everything is on the server.

I create NPC on Server and move it on Client…

why? If you want npc movement to be clientside, then just create it on the client? Also why are you moving it on the client? You want the slime to follow each individual player?

First thing i thought is that i will just create NPC on server so everyone will see it and then move it on each client individually so movement would be smooth. Then when i need i just delete the NPC on server and he will disappear for everyone.

On client i loop through all Zones and for each zone loop through all players and check if any of them inside that zone. If at least 1 player inside - move NPC to him

if you just FireAllClients all the players will see it as well. If you move it on the client then 1 slime can follow any number of players, not sure if this is what you want. This would also mean all the other players can’t see them thus it will look to others like the player is running from nothing. If this is not your intended behavior then i’d recommend switching to server. Also here is where Zones+ V2 would come in handy as you would not need to loop through but connect it to player enter zone events. If you want it to be on the client then just go full client, why bother with replication and latency.

Use a Remote Event to add the NPC and to move, the rest you can do in Client.