So I have a flintlock for my game which uses raycasting and I want to use FindPartOnRay to basically have a bullet mark whenever I shoot, it works but the issue is if the player is moving it has a higher chance of never reaching a part. Also sometimes it's left in the air due to the way it's coded but I don't know how to change it to ignore the player and find out if there's a part where it's hitting..
Here's my script lines 45-52 are the main one's I'm looking at just posted the whole thing to give people a better idea of what's going on..
--Configuration local reloadtime = 1 -- time in seconds local damage = 100 -- damage 1:1 local flash = true -- set true if you want pointlight to be enabled local tk = false -- set true if you want to be able to kill teammates local Distance = 75 -- Calculated in studs local brickColor = BrickColor.new("Dirt brown") --Variables local version = "1.4.0 Fixed issues with configuration's Config will now be found within the gun script." local tool = script.Parent local player = game:GetService("Players").LocalPlayer local halt = 0 local col = script.Parent:FindFirstChild("teamColor") print(version) tool.Equipped:connect(function(mouse) print("Tool equipped!") script.Parent.teamColor.Value = player.TeamColor mouse.Button1Down:connect(function() if halt == 1 then print'reloading' else halt = 1 print("Mouse pressed!") local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) script.Parent.Handle.PewPew:Play() local beam = Instance.new("Part", workspace) beam.BrickColor = BrickColor.new("Black") beam.FormFactor = "Custom" beam.Material = "Plastic" beam.Transparency = 0.25 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = Distance beam.Size = Vector3.new(0.3, 0.3, distance) beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) local hit, position = game.Workspace:FindPartOnRay(ray, player.Character) local p = Instance.new("Part", workspace) p.Anchored = true p.CanCollide = false p.BrickColor = BrickColor.new("Black") p.Transparency = 0 p.FormFactor = "Custom" p.Size = Vector3.new(.2,.2,.2) p.CFrame = CFrame.new(position) local d = script.Parent.SmokePartHandler:Clone() d.Parent = p d.Disabled = false if flash == true then script.Parent.Flash.Flash.Enabled = true script.Parent.Flash.Smoke.Enabled = true wait(0.1) script.Parent.Flash.Flash.Enabled = false script.Parent.Flash.Smoke.Enabled = false end game:GetService("Debris"):AddItem(beam, 0.1) if part then local humanoid = part.Parent:FindFirstChild("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid then if tk == true then if game.Players:FindFirstChild(part.Parent.Name).TeamColor.Name ~= script.Parent.teamColor.Value then humanoid:TakeDamage(damage) else humanoid:TakeDamage(damage) end end end end wait(reloadtime) halt = 0 end end) end)