I need help with scripting

I’m making an rpg with Evercyan’s rpg kit and I’m trying to get the enemy to start following when you hit it instead of when you walk near it, but every time I edit the script it stops working and I don’t know what I’m doing wrong since I don’t know enough about scripting, and the Output doesn’t show any errors.

this is the script:


i highlighted everything i changed from the original script.

Seems like on the 4th and 5th line you typed “Partent” instead of “Parent”. That could be your issue.

i fixed the typo on both but it still doesnt move when i hit it

Assuming that you would want to check to see if the Health is less than the MaxHealth in a function you should put your if statement inside of the function, not the other way around. Along with this, you will have to declare the local variables within the function as well.

Something like this:

function findNearestTorso(pos)
	local Health = script.Parent.Enemy.Health
	local MaxHealth = script.Parent.Enemy.MaxHealth
	if Health < MaxHealth then
		--The rest of your code here
	end
end

i just tried that and nothing changed

Could I see a screenshot of your whole code? Also, could you explain exactly what you’re trying to do, because I am still unsure.

im trying to get the function to start when its hp is less than the max
but when i test the game and attack it, it doesnt move
heres the screenshot of the code
image

heres what happens when i test it