Keeping this line formatted while allowing the Roblox syntax to be understood

  1. What do you want to achieve? I want to limit my PathfindingService call to ComputeAsync to 100 line columns to follow roblox’s lua style guide.

  2. What is the issue? When separating out this function, I get the error Ambiguous syntax: this looks like an argument list for a function call, but could also be a start of new statement; use ';' to separate statements (Most likely because there are two function calls here)

  3. What solutions have you tried so far? I’ve looked for this online, and haven’t found anything

Code formatted
local success, errorMessage = pcall(function()
            if enemy.Parent then
                path:ComputeAsync
                (
                    enemy.PrimaryPart.Position,
                    Vector3.new
                    (
                        closestCharacter.PrimaryPart.Position.X + math.random(0,5),
                        closestCharacter.PrimaryPart.Position.Y + math.random(0,5),
                        closestCharacter.PrimaryPart.Position.Z + math.random(0,5)
                    )
                )
            end
        end)
Code on one line
                path:ComputeAsync(enemy.PrimaryPart.Position, Vector3.new(closestCharacter.PrimaryPart.Position.X + math.random(0,5), closestCharacter.PrimaryPart.Position.Y + math.random(0,5), closestCharacter.PrimaryPart.Position.Z + math.random(0,5)))

Thanks for any help! :smile:

It’s because you need the first parentheses after ComputeAsync and Vector3.new to be on the same line. Try this:

local success, errorMessage = pcall(function()
	if enemy.Parent then
		path:ComputeAsync(
			enemy.PrimaryPart.Position,
			Vector3.new(
				closestCharacter.PrimaryPart.Position.X + math.random(0,5),
				closestCharacter.PrimaryPart.Position.Y + math.random(0,5),
				closestCharacter.PrimaryPart.Position.Z + math.random(0,5)
			)
		)
	end
end)
1 Like

Bro this is a waste of time just don’t even.
Nobody cares if you have a big block of code, just condense it as well as possible for it to still be readable.
Nobody wants you to make some giga long string that is nigh impossible to read and make improvements on later, just use normal format.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.