I’m relatively new to the math.random thing. So I was trying to do this really primitive bullet line bits of code that basically had preset and built bullet lines positioned at the front of the gun with their transparencies set to 1. It would then do a math.random equation thing. If it detected 3, it would activate the bulletline with the number 3, and so on. But for some reason that breaks my FE script. How do I fix or rewrite this?
remot.OnServerEvent:connect(function() --- that's the part from the main gun script that tells the FE script that the gun has fired, and below is what i want to happen once it is fired.
local randomnumber = math.random(1, 3)
if randomnumber == 3 then
script.Parent.BulletLine1.Transparency = 0
if randomnumber == 2 then
script.Parent.BulletLine2.Transparency = 0
if randomnumber == 1 then
script.Parent.BulletLine3.Transparency = 0
end
you have put the other ifs into the first if, you need to make them separate
remot.OnServerEvent:connect(function() --- that's the part from the main gun script that tells the FE script that the gun has fired, and below is what i want to happen once it is fired.
local randomnumber = math.random(1, 3)
if randomnumber == 3 then
script.Parent.BulletLine1.Transparency = 0
end
if randomnumber == 2 then
script.Parent.BulletLine2.Transparency = 0
end
if randomnumber == 1 then
script.Parent.BulletLine3.Transparency = 0
end
end)