Help with moving NPC (Again)

So, you can see the problem in this video, the NPC randomly stop on their way to the destination
The NPC should go to the first destination, which is in front of the door, then go to the chair and sit
But in the video, its not doing the thing!
Video Link:
The Video!

This is the script I used for moving the NPC, its a remote event

The Walking NPC Script
`local Helza = game.Workspace.Helza
local WalkAnim = Instance.new("Animation")
WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=657564596"
local HelzaMoveEvent = game.ReplicatedStorage.Remotes.HelzaMoveEvent


local controller = Helza.Humanoid

local animation = controller:LoadAnimation(WalkAnim)

HelzaMoveEvent.OnClientEvent:Connect(function(EndPosition)
	animation:Play()
	Helza.Humanoid:MoveTo(EndPosition)
	Helza.Humanoid.MoveToFinished:wait()
	animation:Stop()
end)

This is the Idle Animation script, also a remote event

The StartIdle and StopIdle Script
local animidle = Instance.new("Animation")

local HelzaIdleEvent = game.ReplicatedStorage.Remotes.HelzaIdleEvent

animidle.AnimationId = "http://www.roblox.com/asset/?id=657595757"

local HelzaStopIdleEvent = game.ReplicatedStorage.Remotes.HelzaStopIdleEvent

local controller = game.Workspace.Helza.Humanoid

local IdleAnim = game.Workspace.Helza.IdleAnim

local IdleAnimTrack = game.Workspace.Helza.Humanoid:LoadAnimation(IdleAnim)

HelzaIdleEvent.OnClientEvent:Connect(function()

controller:LoadAnimation(animidle):Play()

end)

HelzaStopIdleEvent.OnClientEvent:Connect(function()

controller:LoadAnimation(animidle):Stop() --This stopIdle also not working sadly :(

end)

This is the script that I use to fire it

Script to fire both event
setDialogueImageEvent:FireAllClients(getRandomCharacter(),Color3.new(0.12549, 1, 0.564706)) --Ignore this

createDialogueEvent:FireAllClients("What is it, Miss?") --Ignore this

HelzaStopIdleEvent:FireAllClients()

HelzaMoveEvent:FireAllClients(game.Workspace.Destination1.Position)

wait(5)

setDialogueImageEvent:FireAllClients(game.Workspace.Teacher, Color3.new(0.627451, 1, 0.815686)) --Ignore this

createDialogueEvent:FireAllClients("You gotta sit first, then I will tell it!") --Ignore this

ObjectiveEvent:FireAllClients("Sit in the class!") --Ignore this

ObjectiveTimeEvent:FireAllClients(20) --Ignore this

TimerEvent:FireAllClients(20) --Ignore this

wait(3)

HelzaStopIdleEvent:FireAllClients()

HelzaMoveEvent:FireAllClients(game.Workspace.Destination2.Position)

wait()

HelzaStopIdleEvent:FireAllClients()

wait(3)

game.Workspace.Chair["School C hair"].Seat:Sit(game.Workspace.Helza.Humanoid)

HelzaStopIdleEvent:FireAllClients()

Thanks! I hope anyone can fix this issue!

1 Like

Is “game.Workspace.Destination2.Position” position of the chair? If yes, you need to make NPC walk to the front door first.

– Below this is about the Idle Animation script.
It’s not working is because you make the animation load 2 times and it is a different variable.

You must put local idle = controller:LoadAnimation(animidle) in the script.
Put idle:Play() instead of controller:LoadAnimation(animidle):Play()
Put idle:Stop() instead of controller:LoadAnimation(animidle):Stop()

1 Like

Wait. I forgot to look at HelzaMoveEvent:FireAllClients(game.Workspace.Destination1.Position).

My bad, but is any part inside of the NPC is anchored. Did you make the NPC walk with the anchored part? If you did make NPC walk with the anchored part. It will not walk but The script will think It is walking. And when the script think that the NPC reaches the Destination1 It will walk to the chair without knowing there’s a wall there.

1 Like

nope, the destination 2 is right at the top of the chair
image

and I already make the npc walk to the front door by using destination1

Thanks for the animation idle!

Im pretty sure I already make it all unanchored
image

It might be that the NPC didn’t finish walking to Destination1 and the script makes the NPC walk to Destination2 without finishing to walk to Destination1.

1 Like

exactly what I was thinking about, but then how am I suppose to do like this:
the animation keep walking until its finished to destination1, then it go to destination2, if its not finish then keep walking until finish

local Helza = game.Workspace.Helza
local WalkAnim = Instance.new("Animation")
WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=657564596"
local HelzaMoveEvent = game.ReplicatedStorage.Remotes.HelzaMoveEvent

local controller = Helza.Humanoid
local finishedwalk = true

local animation = controller:LoadAnimation(WalkAnim)

HelzaMoveEvent.OnClientEvent:Connect(function(EndPosition)
	if finishedwalk == true then
		finishedwalk = false
		animation:Play()
		Helza.Humanoid:MoveTo(EndPosition)
		Helza.Humanoid.MoveToFinished:wait()
		animation:Stop()
		finishedwalk = true
	end
end)

this

1 Like

lemme try your code, btw I cant do the sit animation too!

Should I make another topic or no?

Might need to put this with a new Remote event for the sit animation

local sit = controller:LoadAnimation(animsit)

HelzaSitEvent.OnClientEvent:Connect(function()

sit:Play()

end)

HelzaUnsitEvent.OnClientEvent:Connect(function()

sit:Stop()

end)
1 Like

got it, thank you so much for your help!

Also if it doesn’t walk to Destination2 do this

HelzaMoveEvent.OnClientEvent:Connect(function(EndPosition)
	if finishedwalk == true then
		finishedwalk = false
		animation:Play()
		Helza.Humanoid:MoveTo(EndPosition)
		Helza.Humanoid.MoveToFinished:wait()
		animation:Stop()
		finishedwalk = true
	else
		repeat wait() until finishedwalk == true
		finishedwalk = false
		animation:Play()
		Helza.Humanoid:MoveTo(EndPosition)
		Helza.Humanoid.MoveToFinished:wait()
		animation:Stop()
		finishedwalk = true
	end
end)

It does work, unless u got lag a lot that cause npc walk in his seat
like this video:
Untitled Game - Roblox Studio (gyazo.com)
sorry for low quality

1 Like

What if, I want to make the go to sit a.k.a do this thing
game.Workspace.Chair["School Chair"].Seat:Sit(game.Workspace.Helza.Humanoid)
after the npc go to destination2?

HelzaMoveEvent.OnClientEvent:Connect(function(EndPosition)
	if finishedwalk == true then
		finishedwalk = false
		animation:Play()
		Helza.Humanoid:MoveTo(EndPosition)
		Helza.Humanoid.MoveToFinished:wait()
		animation:Stop()
		if EndPosition == game.Workspace.Destination2.Position then
			game.Workspace.Chair["School C hair"].Seat:Sit(Helza.Humanoid)
		end
		finishedwalk = true
	end
end)

If the Position the event gives is equal to Destination2’s Position (Chair’s Position). It will make the NPC sit in Client-Sided.

If you want Server-Sided:

– Walk Script

HelzaMoveEvent.OnClientEvent:Connect(function(EndPosition)
	if finishedwalk == true then
		finishedwalk = false
		animation:Play()
		Helza.Humanoid:MoveTo(EndPosition)
		Helza.Humanoid.MoveToFinished:wait()
		animation:Stop()
		if EndPosition == game.Workspace.Destination2.Position then
			HelzaMoveEvent:FireServer("HelzaSit")
		end
		finishedwalk = true
	end
end)

– Remote firing script

HelzaMoveEvent.OnServerEvent:Connect(Function(plr, functiongive)
	if functiongive == "HelzaSit" then
		game.Workspace.Chair["School C hair"].Seat:Sit(game.Workspace.Helza.Humanoid)
	end
end)

^^^ Replace that on game.Workspace.Chair["School C hair"].Seat:Sit(game.Workspace.Helza.Humanoid)

Did I messed up or what, but the walk animation still playing when sit
image

I use this code

setDialogueImageEvent:FireAllClients(getRandomCharacter(),Color3.new(0.12549, 1, 0.564706))

createDialogueEvent:FireAllClients("What is it, Miss?")

HelzaIdleEvent:FireAllClients()

HelzaMoveEvent:FireAllClients(game.Workspace.Destination1.Position)

HelzaMoveEvent:FireAllClients(game.Workspace.Destination2.Position)

wait(5)

setDialogueImageEvent:FireAllClients(game.Workspace.Teacher, Color3.new(0.627451, 1, 0.815686))

createDialogueEvent:FireAllClients("You gotta sit first, then I will tell it!")

ObjectiveEvent:FireAllClients("Sit in the class!")

ObjectiveTimeEvent:FireAllClients(20)

TimerEvent:FireAllClients(20)

wait(4)

game.Workspace.Chair["School C hair"].Seat:Sit(game.Workspace.Helza.Humanoid)

Where is HelzaStopIdleEvent:FireAllClients()?

1 Like

where should I put it? i dont know where I should put it

Under game.Workspace.Chair["School C hair"].Seat:Sit(game.Workspace.Helza.Humanoid).