Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
AyeJude 41
6 years ago

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
0
Could you not use a for loop? robloxianmirror 57 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
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
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.  Ribasu 127 — 6y
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. AyeJude 41 — 6y
Ad

Answer this question