Video:
Code:
local Bullet = game.ReplicatedStorage.Objects.VFX.Bullet:Clone()
local Range : number = Config.Range
local Speed : number = Config.Speed
local FlightTime : number = Speed * Range
local ShootPart : CFrame = Gun.ShootPart.CFrame
local LookAt = CFrame.lookAt(ShootPart.Position, Hit.Position)
Bullet.PrimaryPart.CFrame = ShootPart
Bullet.Parent = game.Workspace.Bullets
Bullet.Body.Trail.Color = Colors[GunData[Gun.Name].LazerType]
local Current : Vector3, Last : Vector3 = ShootPart.Position, ShootPart.Position
Bullet.Body.Pos.Position = ShootPart.Position
Bullet.Body.BrickColor = (function()
local Data = GunData[Gun.Name]
if Data.LazerType == Enum.LazerColors.Blue then
return BrickColor.new("Deep blue")
elseif Data.LazerType == Enum.LazerColors.Red then
return BrickColor.new("Really red")
else
return BrickColor.new("Yellow flip/flop")
end
end)()
coroutine.wrap(function()
local Suc, Fail = pcall(function()
for Num = 0, Range, ((Range / FlightTime) * 60) * Config.BulletSpeedMultipler do
local CF = CFrame.new(Bullet.PrimaryPart.Position, Current)
Bullet.Body.Pos.Position = Current
Bullet.PrimaryPart.Orientation = GetRot(CF)
Bullet.Body.AlignOrientation.PrimaryAxis = GetRot(CF) --Vector3.new(CF:ToEulerAngles())
Current = ShootPart.Position + (LookAt.LookVector * Num) - Vector3.new(0, -.1 * Num ,0)
Last = Current
RS.Heartbeat:Wait()
end
end)
if Fail then
Bullet:Destroy()
end
end)()