so I'm trying to create a bullet trail for a gun I'm making, this is what ive got so far(not do with the a trail)
local targetPoint = MyMouse.Hit.p
local shootDirection = (targetPoint - Handle.Position).unit
-- Adjust the shoot direction randomly off by a little bit to account for recoil
shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
(0.5 - math.random()) * 2 * Spread,
(0.5 - math.random()) * 2 * Spread) * shootDirection
local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
local bullet
local bulletrail
-- Create a bullet here
if hitObject then
bullet = CreateBullet(bulletPos) -- creates a bullet hole in the desired point
bulletrail = bullettrail(shootDirection,bulletPos,targetPoint) -- create bullet trail, what parameters would I need?
end
-- the bullettrail function
local function bullettrail (shootDirection,bulletPos,targetPoint)
Instance.new("Part",workspace)
local P = Instance.new("Part")
P.Name = "BulletTrail"
local Place0 = script.Parent.Parent["Right Arm"].CFrame
P.formFactor = 0
P.Size = Vector3.new(1,1,(Place0 - shootDirection).magnitude)
P.CFrame = CFrame.new((Place0 + shootDirection)/2,Place0)
P.Parent = script.Parent.Parent
P.BrickColor = BrickColor.Yellow()
P.Anchored = true
P.CanCollide = false
local m = Instance.new("BlockMesh")
m.Scale = Vector3.new(0.1,0.1,1)
m.Parent = P
end
so I'm just playing around with it and I'm sure sure I quiet understand raycasting and stuff enough to create a bullet trail, I have looked at the wiki - {magnitudes, and creating rays} but certain things I didn't understand, so if someone would help explain, that would be amazing, thanks a lot! :) ~Bubs
