I'm working on a gun right now which fires out bullets. I want them to go through objects that have collision turned off (borders, hidden parts, etc.), but they stop when they reach the object. Also hit.Name can't seem to detect the bullet. It'll return the name for any object that touches the parent of a script that has it but it can't detect the bullet.
Here's the server script. I got most of it off of a tutorial here: https://devforum.roblox.com/uploads/short-url/WQW6iS1i344HHrPXbvyIA1pUWV.rbxl and the page that goes along with it is here: https://devforum.roblox.com/t/how-to-make-ranged-weapons-with-bullet-movement/606618/2
Any help is appreciated :) I'm new to Lua scripting so I would prefer answers that give me the entire working script to copy and paste in.
Once again, the problems are that the bullets don't go through objects with collisions and that other objects cannot detect a hit by them. This is only part of the weapon so it'll help to reference the whole tutorial for the other parts and scripts.
local weapon = script.Parent local fireRemote = weapon.Fire local configs = weapon.Configuration local speed = configs.Speed.Value local dropDistance = configs.DropDistance.Value local damage = configs.Damage.Value local dropAngle = configs.DropAngle.Value local function CreateFire(startPosition, direction) local ray, object, position local bullet = Instance.new("Part") bullet.Name = "Bullet" bullet.FormFactor = Enum.FormFactor.Custom bullet.Anchored = true bullet.CanCollide = false bullet.Massless = true bullet.Locked = true bullet.Parent = game.Workspace local function RayCast() ray = Ray.new(bullet.CFrame.p, bullet.CFrame.LookVector * speed) object, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, {weapon.Parent}, false, true) local dropDamageModifier = (position - startPosition).Magnitude/dropDistance local _damage = damage/dropDamageModifier if _damage > damage then _damage = damage end if _damage < 1 then _damage = 0 game:GetService("Debris"):AddItem(bullet, 0.01) bullet = nil end if object and bullet then local humanoid = object.Parent:FindFirstChildWhichIsA("Humanoid") if humanoid then humanoid:TakeDamage(_damage) end game:GetService("Debris"):AddItem(bullet, 0.01) bullet = nil end end bullet.Color = Color3.fromRGB(255, 150, 0) bullet.Material = Enum.Material.Neon bullet.Transparency = 0 bullet.Size = Vector3.new(0.2, 0.2, 2) bullet.CFrame = CFrame.new(startPosition, startPosition + direction) * CFrame.new(0, 0, 1.4) RayCast() local createBulletTrajectory = coroutine.wrap(function() while bullet do bullet.CFrame = bullet.CFrame * CFrame.new(0, 0, -speed) * CFrame.Angles(-dropAngle, 0, 0) RayCast() wait() end end) createBulletTrajectory() end fireRemote.OnServerEvent:Connect(function(player, mousePos, startPos) local direction = (mousePos - startPos).Unit CreateFire(startPos, direction) end)