How would you make a bot/npc run away from a player if the player gets to close, and when you kill the bot how would you make it drop something, like a brick.

In conclusion how would you reverse a humanoid following you? I wrote this script but it doesnt seem to work on the bot/NPC

local phase = script.Parent.Phase
local h = script.Parent.Humanoid

while true do
	game.Workspace:WaitForChild("Player")
	local plr = game.Workspace:FindFirstChild("Player")
	if phase.Value == "Run" then
		script.Parent.Torso.Velocity = plr.Torso.CFrame.lookVector * 16
--		h:Move(Vector3.new(math.random(-1,1), 0, math.random(-1,1)), true)
	end
	wait()
end

Where would I put the script after the revisions that have been made? (if there were any)

Thanks =)

2 comments

0

Could you please format your code?

0

I did can you help me ?