Which practice is better?

local bp = Pet.BodyPosition

while true do
	wait()
	bp.Position = --a vector 3 position
end

OR


while true do
	wait()
	Pet.BodyPosition.Position = --a vector 3 position
end

6 comments

0

bp is nil in the loop in the first script

0

But let's say that Pet is already defined

2

You should make variable outside the loop it is a constant value

0

@MC wrong

0

Matter of style mainly - do whichever you personally prefer. The first is technically faster, but unless the section of code you're running it in is REALLY hot, you won't see a noticeable difference.

0

If you're going to use bp a lot, then set a variable for it.