I have been trouble finding a good method to raycast from one point to the mouse, because of super odd results like this:
A snippet of the code that handles the raycasting:
local ignorelist = {}
table.insert(ignorelist,game.Workspace.Trash) -- Tracers, bulletholes, etc
table.insert(ignorelist,game.Workspace.WeaponPreview) -- The gun your seeing in the MP4
table.insert(ignorelist,plr.Character)
local ray = Ray.new(point,(mouse - point)) -- Point is the tip of the gun, mouse is mouse.hit.p
local part, pos, norm = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignorelist)
I tried .Unit (I don’t have the code from back when) but this produced off results close-up as shown:
Can you include the “point” variable? Nothing seems to be off, to me at least.
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,id,gun,mouse,point)
game.ReplicatedStorage.RemoteEvent:FireServer(1,char[gun.Name],mouse.Hit.p,gun.FirePoint.Position,lastshot)
I’m aware of the security issues, its not a problem right now.
Since I don’t really see any issue with the code itself, I think there’s an issue with which parts are being ignored. Could you possibly give all the items being parented to game.Workspace.Trash? Also WorldRoot:FindPartOnRay and everything in that genre such as WorldRoot:FindPartOnRayWithIgnoreList is deprecated. Here is everything you need to know about the new ray casting method:
And here’s an article on the basics to the new method:
I just heard about the new raycast method, it had me stoked. I’m giving it a shot.
Alright, I’ve ran into attempt to call a table value error trying to un-deprecate my code on this line:
raycastParams.FilterDescendantsInstances({game.Workspace.Trash,game.Workspace.WeaponPreview,plr.Character})
Im confused since on the devhub it asks for an array.