So I keep getting the error
''Workspace.MovingSharks.Script:9: bad argument #2 to '?' (string expected, got Object)"
I've tried and tried again but to avail, What's wrong?
local movingpeices = script.Parent.MoveToPieces:GetChildren() local sharks =script.Parent:GetChildren() while wait() do wait(1) for i,v in pairs (sharks) do if script.Parent.Shark.Name == "Shark" then local target = movingpeices[math.random(1, #movingpeices)] local path = game:GetService("PathfindingService"):ComputeRawPathAsync(script.Parent.Shark.Torso.Position, target.Position, 500) local points = path:GetPointCoordinates() if path.Status == Enum.PathStatus.Success or Enum.PathStatus.ClosestNoPath then repeat wait() until points ~= nil for i = 1, #points do script.Parent.Shark.Humanoid:MoveTo(points[i]) end end end end end
You need to use the Object's name in the square brackets, rather than the object itself. You're doing script.Parent[v], you need to do script.Parent[v.Name].