I have a loop here, from i = 0, 1. But for some reason, I’m not able to use if statements to check the value of i over .7
Code
local module = {}
local function QuadBezier(t, p0, p1, p2)
return (1 - t)^2 * p0 + 2 * (1 - t) * t * p1 + t^2 * p2
end
module.CreateLightning = function(startPos,finalPos,segments) --[segments is 10 bc i put 10 in the server script. So it will increment by .1]
local thickness = .2 --[do u want a thicc lightning or a skinny lightning?]
local XoffsetMin, XoffsetMAX = -1,1 --[controls how spread out it is]
local YoffsetMIN, YoffsetMAX = -1.5,1.5 --[the bigger the range, the uglier the lightning]
local ZoffsetMIN, ZoffsetMAX = -1,1 --[controls how spread out it is]
local LerpPos = {}
local origin = startPos
local destination = finalPos
local curve = (origin + destination)/2
for i = 0, 1, 1/segments do
local offset = Vector3.new(math.random(XoffsetMin,XoffsetMAX),math.random(YoffsetMIN,YoffsetMAX),math.random(ZoffsetMIN,ZoffsetMAX))
if i == 0 or i == 1 then --[PROBLEM OCCURS HERE. It stops detecting i when i = .7]
print('detecting i')
offset = Vector3.new(0,0,0) --[set it back in line, so that it ignores the offset]
end
LerpPos[#LerpPos + 1] = QuadBezier(i, origin,curve,destination) + offset
print(i) --[it prints i, from 0 to 1]
end
end
return module
It prints out i just fine, but I can’t check if i == .8 or if i == .9 or if if == 1. I tried prints as well within the loop. Like
if i == 1 then
print('aslkjdasd')
end
but it literally won’t work??? I’m really lost someone help me. The reason I’m doing this is because I’m trying to make this lightning strike, and the part at the final position is offsetted from the final position, and I don’t want it to be.
As you can see if the photo below, the bottom part is the start position, and that’s when i = 0. And at the top, you can see it has the offset, and that’s when i = 1. I want it to be at the center of the part. Help