Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

i was coding a tower defense game and I cant seem to get the moving script right?

Asked by 2 years ago

local zombie = script.Parent local waypoints = workspace.waypoints

for waypoint=1, #waypoints:getchildren() do zombie.Humanoid:MoveTo(waypoints[waypoint].position) zombie.Humanoid.MoveToFinished:Wait() end

0
What is your issue? enes223 327 — 2y
0
my problem is waypoints is not a valid member of Workspace "Workspace" Emereldboy 0 — 2y

1 answer

Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

The issue is that you are trying to index Waypoints with the number you get from the for loop, you should use pairs or ipairs for the loop. Fixed scripts:

local zombie = script.Parent local waypoints = workspace.waypoints

for WaypointIndex, Waypoint in pairs(waypoints:GetChildren()) do
    zombie.Humanoid:MoveTo(Waypoint.position) 
    zombie.Humanoid.MoveToFinished:Wait()
 end
0
it didnent work Emereldboy 0 — 2y
Ad

Answer this question