Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

What is your issue?

0

my problem is waypoints is not a valid member of Workspace "Workspace"

1 answer

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

1 comment

0

it didnent work

This discussion is preserved as it was. New answers, comments, and votes are closed.