Good morning guys, i have this error, that is very very weird, just for the fact that i have did this before and this didnt even give me this error while raycasting other guns that i have coded. I have thought that the problem may be my “BodyAttach” part, that is just a part that cointains motor6ds and sounds for the gun, but when i dont put anything on the FilterDescendantsInstances() brackets, the error stills appearing. Here i leave my code, also this is a LocalScript
local WeaponTool = script.Parent.MP40 local function shoot() local now = tick() if now - lastFire >= shootDelay then lastFire = now local origin = WeaponTool.ShootPart.Position local destination = mouse.Hit.Position local direction = (destination - origin).Unit*700 local raycastParams = RaycastParams.new() raycastParams.FilterDescendantsInstances(WeaponTool) raycastParams.FilterType = Enum.RaycastFilterType.Blacklist local result = workspace:Raycast(origin, direction, raycastParams) local intersection = result and result.Position or origin + direction local distance = (origin - intersection).Magnitude onShootEvent:FireServer(distance, result, intersection, origin, lastFire, shootDelay) SoundEvent.OnClientEvent:Connect(function(plr, shootsound) shootsound:Play() end) Bullets.Value -= 1 local shootAnimation = Instance.new("Animation") shootAnimation.AnimationId = "rbxassetid://5671559974" local shootAnimTrack = char:WaitForChild("Humanoid"):LoadAnimation(shootAnimation):Play() else --Let use know they have to wait, if you want too end end
Thanks in advance!!!