Hello, I have a problem. I created a gun which works pretty well except it has a bug as shown in the gif below (sorry for bad quality) The bullets are overlapping causing this effect. Any ideas on how to fix this? Thanks!
1 Like
Can we see your script please, there is no way for us to help you if we don’t know how you scripted it.
1 Like
ok
local Debris = game:GetService("Debris")
local BeamFolder = game.Workspace.Beams
local range = 300
function MakeRayVisible(origin,direction)
local midpoint = origin + direction/2
local Part = Instance.new("Part",BeamFolder)
Part.Anchored = true
Part.CanCollide = false
Part.Material = Enum.Material.Neon
Part.Color = Color3.fromRGB(255, 255, 255)
Part.Transparency = 0.5
Part.CFrame = CFrame.new(midpoint,origin)
Part.Size = Vector3.new(.5,.5,direction.magnitude)
Debris:AddItem(Part,0.8)
end
script.Parent.ShootEvent.OnServerEvent:Connect(function(player,mousePos,originPos)
local paremeters = RaycastParams.new()
paremeters.FilterDescendantsInstances = {player.Character}
paremeters.FilterType = Enum.RaycastFilterType.Blacklist
local direction = (mousePos - originPos).Unit * range
local result = workspace:Raycast(originPos,direction,paremeters)
if result then
local humanoid = result.Instance.Parent:FindFirstChild("Humanoid")
if humanoid then
if result.Instance.Name ~= "Head" then
humanoid:TakeDamage(25)
else
humanoid:TakeDamage(100)
print("BOOM!!! Headshot!")
end
end
end
MakeRayVisible(originPos,direction)
end)
1 Like
Probably because the mouse doesn’t ignore the created bullets?
2 Likes
It is, but I’m trying to figure out a solution
Any way to ignore it with mouse.hit.p or the ray?
1 Like
Mouse.TargetFilter = BeamFolder
2 Likes
let me try that… 30 letters lol
1 Like
DUDE THANK YOU SO MUCH, this is so helpful
1 Like