Made a tracer effect that uses beams to replicate bullet tracers. The tracer is made up of Beams and Attachments. The attachment uses TweenService to move to RaycastResult.Position
The functionality of the script works as intended, the only issue I am facing now is the inconsistency on how the bullet tracers sometimes fully reach the RaycastResult and how it just stops midpoint. I tried messing with the Beam properties…but nothing much reach changed.
I did find a solution to this using Task.wait() before setting the beam position back to the original position, but I am afraid this may mess the timing up of other guns in the future.
local Point = tool.Handle.Point
local PointLookVector = Point.CFrame.LookVector
local RaycastParams = RaycastParams.new()
RaycastParams.FilterDescendantsInstances = {tool.Parent}
RaycastParams.FilterType = Enum.RaycastFilterType.Exclude
local Point = tool.Handle.Point
local doDmgRE = tool:WaitForChild("DoDamage")
local RaycastResult = workspace:Raycast(Point.Position, PointLookVector * 500, RaycastParams)
local function BulletRay()
if RaycastResult == nil then
print("Jammed")
else
local RayDistance = RaycastResult.Distance
local RayPosition = RaycastResult.Position
print(RayPosition)
local Silencer = tool.Handle.Silencer
local bp0 = Silencer.beamPart0
local bp1 = Silencer.beamPart1
local beam = Silencer.Beam
beam.Enabled = true
local TweenService = game:GetService("TweenService")
local Tweeninfo = TweenInfo.new(0.1 , Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = TweenService:Create(bp1, Tweeninfo, {Position = RayPosition})
tween:Play()
tween.Completed:Connect(function()
bp1.Position = bp0.Position
end
end
end
BulletRay()