Hey all,
I'm trying to create a gun trail (first time) and the trail its self is working and is being created however the HumanoidRootPart.CFrame.LookVector being passed from a localscript into a server script is printing values very close to 0,0,0 example: -0.332323, -0, 0.42422 This is the following code of the trail effect:
local ray = Ray.new(gun.Handle.CFrame.p, (workspace[Sheriff.Name].HumanoidRootPart.CFrame.LookVector - gun.Handle.CFrame.p).unit * 300)
local part, position = game.Workspace:FindPartOnRay(ray, Sheriff_Char, false, true)
local distance = (gun.Handle.CFrame.p - position).magnitude
if game.Workspace:FindFirstChild(Sheriff.Name.."'s Trajectory") then --Destroy the last bullet trail if there is one
game.Workspace:FindFirstChild(Sheriff.Name.."'s Trajectory"):Destroy()
end
local trajectory = Instance.new("Part", game.Workspace) --Create bullet trail
trajectory.BrickColor = BrickColor.new("Institutional white")
trajectory.Material = "SmoothPlastic"
trajectory.Name = Sheriff.Name.."'s Trajectory"
trajectory.Transparency = 0.9
trajectory.Anchored = true
trajectory.Locked = true
trajectory.CanCollide = false
trajectory.Size = Vector3.new(0.1, 0.1, distance)
for i = 0, distance, 6 do --Bullet Trail will keep expanding until it hits something or runs out of range.
trajectory.CFrame = CFrame.new(gun.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
end
Here is a gif of what I mean: https://gyazo.com/c77f8d08c94db17d3d24e5d63ef5d6dd
My attempt is to not use the mouse as a variable of position because my plan is to use a top down camera with the mouse centered on the screen at 0,0,0 meaning I want the trail to travel the direction the humanoid is looking in.
I really appreciate everyone's help, been trying to figure this out for a couple hours and I need a break aha

1 comment
No need to put [SOLVED] in the title, a mod can do that for you.