Control npc from a distance using script

I am attempting to make a system that moves a NPC based on buttons at a point in the map. I wrote this but its not working correctly. Plus I don’t know how to make it to where it will add a value to walk to point instead of just a specific point in the map.

(The script is for large buttons players have to stand on)

debounce = false

script.Parent.Touched:connect(function(hit)
	if not debounce then
		debounce = true
		if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			workspace.NPC.Humanoid.WalkToPoint()
			wait(2)
		end
		debounce = false
	end
end)
1 Like