Hi, I’ve been using a tutorial on how to create a Tower Defense game and I’m currently trying to figure out how to remove the Time Out on the MoveTo in this function:
function mob.Move(mob, map)
local targetreached = true
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = map.Waypoints
for waypoint=1, #waypoints:GetChildren()do
mob.MovingTo.Value = waypoint
humanoid:MoveTo(waypoints[waypoint].Position)
humanoid.MoveToFinished:Wait()
end
mob:Destroy()
map.Base.Humanoid:TakeDamage(humanoid.Health)
end
I’ve tried this and it didn’t help, instead it just instantly ended and the enemies immediately died.
Here is the Roblox Tutorial I was following:
Any help on this I can get would be greatly appreciated.
I had made a tower defense game and came across this issue. My fix to it was to repeat the moveto until it was returned as “successful”.
function mob.Move(mob, map)
local targetreached = true
local humanoid = mob:WaitForChild("Humanoid")
local waypoints = map.Waypoints
for waypoint=1, #waypoints:GetChildren()do
mob.MovingTo.Value = waypoint
repeat
humanoid:MoveTo(waypoints[waypoint].Position)
local reached = humanoid.MoveToFinished:Wait()
until reached
end
mob:Destroy()
map.Base.Humanoid:TakeDamage(humanoid.Health)
end
as humanoid.MoveToFinished:Wait() returns whether it successfully reached the point or not.
This definitely seems to have solved the issue. Thank you! If I run into anymore problems with this I’ll continue to post here. Otherwise we’re looking good here.