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

Is there a way to use vector3 more efficiently or is there something better than vector3?

Is there a better and more efficient way to do this that dosen't take up has much lines?

local function AimF(plr)
wait(.001)
plr.Character.Humanoid.CameraOffset = Vector3.new(0.05, -0.05, -0.05)
wait()
plr.Character.Humanoid.CameraOffset = Vector3.new(0.1, -0.1, -0.15)
wait()
plr.Character.Humanoid.CameraOffset = Vector3.new(0.15, -0.15, -0.25)
wait()
plr.Character.Humanoid.CameraOffset = Vector3.new(0.2, -0.2, -0.35)
wait()
plr.Character.Humanoid.CameraOffset = Vector3.new(0.25, -0.25, -0.45)
wait()
plr.Character.Humanoid.CameraOffset = Vector3.new(0.3, -0.3, -0.55)
wait()
plr.Character.Humanoid.CameraOffset = Vector3.new(0.3, -0.3, -0.55)
end

1 comment

0

Could you not use a for loop?

1 answer

for i = 1, 6 do
	plr.Character.Humanoid.CameraOffset = Vector3.new(0.05 + (0.05*i), -0.05 - (0.05*i), -0.05 - (0.1*i))
	wait()
end

2 comments

0

This is the answer if you want less lines of code. Efficiency in terms of processing time and storage requirements are pretty much the same.Remember that it works because there is a pattern associated with the XYZ values being passed to Vector3- it will become a bit more complicated if there is a more complex pattern. 

0

Thanks, I didn't want to just steal the script so I decided to learn about loops, and I actually understand this. The script will basically loop 6 times by default because you didn't tell it how much to go by. Thank you.

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