Whenever my gun is inside the wall it either seemingly doesnt fire (I assume its going into the wall so Im fine with it) or reflects off of it for no reason, how can I fix this.
Example:
https://gyazo.com/0b1fefa5b7043328ad0812e962baf90f
local endpos
local BulletStart = firepart
local Dir = (mousehit - BulletStart).Unit
local Shoot = workspace:Raycast(BulletStart, Dir * range, Params)
if not Shoot then
endpos = BulletStart + Dir * range
local sound2 = Instance.new("Sound")
sound2.Name = "BulletSound"
sound2.Parent = plr.Character
sound2.SoundId = "rbxassetid://7521476935"
sound2.Volume = 1
sound2:Play()
game:GetService("Debris"):AddItem(sound2, 2)
print(Shoot)
else
endpos = Shoot.Position
print(Shoot)
if Shoot.Instance.Parent:FindFirstChild("Humanoid") then
if Shoot.Instance.Name == "Head" then
Damage(Shoot.Instance.Parent:FindFirstChild("Humanoid"),65,"rbxassetid://5710435840", plr.Character)
else
Damage(Shoot.Instance.Parent:FindFirstChild("Humanoid"),35,"rbxassetid://626985498", plr.Character)
end
else
local sound = Instance.new("Sound")
sound.Name = "BulletSound"
sound.Parent = Shoot.Instance
sound.SoundId = "rbxassetid://4334512139"
sound.Volume = 0.4
sound:Play()
game:GetService("Debris"):AddItem(sound, 2)
end
end