hola,

it's me again, D3vBhavesh. SO. im basically trying to make my npc move and damage other players. this is basically an enemy ai sorta thing im working on and since i dont have that much knowledge in terms of scripting ???? i was following a tutorial on yt.

scripts: (btw me can understand like most of the stuff typed out in the scripts. i just dont know how to fix the moving script thingy for my enemy ai/npc)

move script:

local target = nil

while wait () do
	for i, v in pairs(game.Workspace:GetChildren()) do
		if v:FindFirstChild("Humanoid") and v:FindFirstChild("Humanoid") then
			local humanoid = v:FindFirstChild("Humanoid")
			local humanoidrootpart = v:FindFirstChild("HumanoidRootPart")
			if humanoidrootpart and humanoid then
				if humanoid.Health > 0 then
					if (script.Parent.HumanoidRootPart.Position - humanoidrootpart.Position).magnitude < 30 then
						target = humanoidrootpart
						if target ~= nil then
							script.Parent.Humanoid:MoveTo(target.Position)
						end
					end
				end
			end
		end
	end
end

and another quick question; why do i need a wait when i wont use it? some pplz use it but dont have an input in the parentheses. whats the use of that then?

please lmk how me can fix this problem and the answer to this question

arigato & sayonara ^^

2 comments

0

Did you delete the current script?

0

wdym?