I changed the player:CharacterAdded:Wait() to player.CharacterAdded:Wait()
And disabled the animation for testing purposes.
The scripts seems to work fine, but, I had to give the NPC’s NetworkOwnership to the client, so the client can move the NPC, now its walking correctly to all points in map.
But that takes me to a question… In order to move an NPC on client side, we should give the NetworkOwnership to all clients?.. that sounds not possible
– Local Script in StarterCharacterScripts:
local NPC = game.Workspace.R6
local humanoid = NPC.Humanoid
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
--AnimationWalkTrack.Looped = true
--AnimationWalkTrack:Play()
NPC.Humanoid:MoveTo(game.Workspace.NPCS.Points.PT1.Position)
NPC.Humanoid.MoveToFinished:Wait()
wait(1)
NPC.Humanoid:MoveTo(game.Workspace.NPCS.Points.PT2.Position)
NPC.Humanoid.MoveToFinished:Wait()
wait(1)
NPC.Humanoid:MoveTo(game.Workspace.NPCS.Points.PT3.Position)
NPC.Humanoid.MoveToFinished:Wait()
A server script which handles the NetworkOwnership for the client that joins:
That for sure fix the issue I found, where I had to give the ownership to client.
If the NPC is cloned and parented to workspace by the client, surely that fix that issue
Weird, I used your script and works for me when I gave the ownership to client.
But dont try that, would be better if you make the client Clone the NPC and parent it to workspace, that will let the client to move the NPC
Yup, thats exactly what I noticed the first time I tried your script, after the push started to walk, thats why I changed the NetworkOwnership to the client. After that the NPC always walks without the push
When your character collides with the NPC, the NetworkOwnership changes to belong to your character:
Anyway, the best way is to Clone the NPC and parent it to workspace via the client, to avoid this issue
There is also a “AutoHipheight” box you can tick, if you have trouble defining a custom hipheight. But a character wont move correctly if hipheight aren’t set correctly.