So well, I'm a pretty experienced scripter in certain places. But I've rarely ever work with raycasting. I'm basically just starting so bare with me..

I've made a pretty simple gun using raycasting but it's got a problem

Basically the bullets shooting from the gun collides with the bullet that was previously shot.

I want to be able to fire bullets through each other but I'm not sure how.

I'm assuming it'd have something to do with FindPartOnRayWithIgnoreList but I'm not sure how to add the bullet to that. I tried adding all the bullets to a folder and adding the children of that folder to the ignore list but it's returned with Unable to cast value to object and so I'm stuck

I'm pretty sure the answer is pretty simple seeing as most people don't seem to have this issue. Here's part of my script

local ray = Ray.new(muzzle.CFrame.p, (mouse.p - muzzle.CFrame.p).unit * range)
	local ignorelist = {plr.Character,muzzle}
	local hit, position, rebound = workspace:FindPartOnRayWithIgnoreList(ray, ignorelist, true, true)
local length = (muzzle.CFrame.p - position).magnitude
	
local bullet = Instance.new("Part",workspace.Bullets)
bullet.BrickColor = BrickColor.new("Institutional white")
bullet.Transparency = 0.4
bullet.Name = "Bullet"
bullet.Material = Enum.Material.Neon
bullet.Anchored = true
bullet.CanCollide = false

bullet.Size = Vector3.new(0.1, 0.1, length)
bullet.CFrame = CFrame.new(muzzle.CFrame.p, position) * CFrame.new(0,0,-length/2)

It's literally very basic. Any help would be appreciated (I'll mark it as answered too, if it worked (some people don't))

3 comments

0

By the way, I'm also going to do a shotgun pretty soon, and this issue would very much affect that.

0

You shouldn't post those questions here because people on this site to be honest, aren't that good at scripting. I suggest you use the official https://devforum.roblox.com

0

Alright I'll give it a shot.