I want to improove the beam to follow the gun more fluid.
this is my main tool script
local caster = script.Parent.Handle.caster
local npc = workspace.NPC.Torso
script.Parent.Equipped:Connect(function()
local attach01 = Instance.new("Attachment")
local attach02 = Instance.new("Attachment")
local beam = Instance.new("Beam")
local particleFire = Instance.new("ParticleEmitter")
particleFire.Texture = "http://www.roblox.com/asset/?id=242856226"
local colorKeypoints = {
-- API: ColorSequenceKeypoint.new(time, color)
ColorSequenceKeypoint.new( 0, Color3.new(1, 1, 1)), -- At t=0, White
ColorSequenceKeypoint.new(.5, Color3.new(1, .5, 0)), -- At t=.5, Orange
ColorSequenceKeypoint.new( 1, Color3.new(1, 0, 0)) -- At t=1, Red
}
particleFire.Color = ColorSequence.new(colorKeypoints)
particleFire.LightEmission = 1
particleFire.LightInfluence = 1
particleFire.ZOffset = 0
particleFire.Acceleration = Vector3.new(0, -20, 0)
particleFire.EmissionDirection = Enum.NormalId.Top
particleFire.Lifetime = NumberRange.new(0.5,1)
particleFire.Rate = 75
particleFire.Speed = NumberRange.new(0, 10)
particleFire.SpreadAngle = Vector2.new(25,25)
particleFire.Parent = attach02
attach01.Parent = caster
attach02.Parent = npc
beam.Attachment0 = attach01
beam.Attachment1 = attach02
-- appearance properties
beam.Color = ColorSequence.new({ -- a color sequence shifting from white to blue
-- API: ColorSequenceKeypoint.new(time, color)
ColorSequenceKeypoint.new( 0, Color3.new(1, 1, 1)), -- At t=0, White
ColorSequenceKeypoint.new(.5, Color3.new(1, .5, 0)), -- At t=.5, Orange
ColorSequenceKeypoint.new( 1, Color3.new(1, 0, 0)) -- At t=1, Red
}
)
beam.LightEmission = 1 -- use additive blending
beam.LightInfluence = 0 -- beam not influenced by light
beam.Transparency = NumberSequence.new({ -- beam fades out at the end
NumberSequenceKeypoint.new(0, 0),
NumberSequenceKeypoint.new(0.5, 0),
NumberSequenceKeypoint.new(1, 1)
}
)
beam.ZOffset = 0 -- render at the position of the beam without offset
-- shape properties
beam.CurveSize0 = 5 -- create a curved beam
beam.CurveSize1 = -2 -- create a curved beam
beam.FaceCamera = true -- beam is visible from every angle
beam.Segments = 5 -- default curve resolution
beam.Width0 = 0.5 -- starts small
beam.Width1 = 4 -- ends big
beam.Parent = caster
end)
script.Parent.Unequipped:Connect(function()
npc:FindFirstChild(“Attachment”):Destroy()
end)
in another script i update the beam position this way
while true do
script.Parent.CFrame = script.Parent.Parent.CFrame
wait(0.001)
end
thanks i really apreciate your help.