I have a slime and I'm trying to make it move to the Player's position but when it runs the code below nothing happens except for a lag spike every 7 seconds.
wait(0.2)
while true do
script.Parent:FindFirstChild("Range").Touched:Connect(function(other)
if other.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(other.Parent)
if player then
wait(7)
script.Parent.Humanoid:MoveTo(player.Humanoid.Position)
end
end
end)
wait(0.2)
end
MoveTo functions works with a vector3 but when I try to input the player's coordinates it breaks.
P.S. I added a humanoid to a model I made without a humanoid. I also added the Torso, Head, and root part. Maybe I stuffed up there?
Thanks

2 comments
Thank you so much! It works great and I'll look into other methods of moving the enemy that don't involve the Humanoid class.
I'm glad I could help @NaNo :)