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 14 days 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 177 — 13d
0
my problem is waypoints is not a valid member of Workspace "Workspace" Emereldboy 0 — 13d

1 answer

Log in to vote
0
Answered by
enes223 177
13 days 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 — 13d
Ad

Answer this question