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.
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
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