Hi, I've been at this for hours. I teach kids game development, and they've recently been asking to do a Roblox mod. I don't know how to do this, but I figured I can make a lesson plan over the next few months so we can do it next year. I'm trying to get an NPC to move, but I'm having trouble.
Here is my code currently:
function Enemy:OnCreate()
while (true) do
wait(2)
local target = self:GetNearestPlayer()
if (target) then
local torso = target:GetTorso()
self.object.NPC.Humanoid:MoveTo(torso.Position, torso)
end
end
end
I am using CodeKingdoms because it is easier for my students to understand. If someone could help me out that would be awesome. Thanks!

5 comments
what you teach students code that isn't yours? i'm confused
How and when is the function executed?
Is it anchored?
It is my code. CodeKingdoms just makes it node based. Easier for kids to grasp.
It is not anchored. And it is in OnCreate