Raycast returns nil

I’ve tried commenting out ignorelist- it is not the cause. This has been a major issue for 3 days now and it makes me want to smash my monitor.

Snippet of code that handles raycast:

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {game.Workspace.Trash,plr.Character}
	-- Point is the tip of the gun position, and mouse is Mouse.Hit.p
local ray = Ray.new(point,(mouse - point).Unit*1000)
local rayresult = workspace:Raycast(point,(mouse - point),raycastParams)

Any help is really appreciated… Multiple people have tried but then suddenly stopped responding.

3 Likes

local rayresult = workspace:Raycast(point, (mouse - point).Unit * 1000, raycastParams)
i think is what you meant
also you dont need this line

local ray = Ray.new(point,(mouse - point).Unit*1000)

Oops; meant to remove that. That fixes all my guns except the Garand. It appears to fire from under the map, I can’t put my finger on the cause. The point is directly from the tip of the gun; and the part is in the correct position.

image

if that is the problem, the error must lie in the Point variable. If you show where you define it, i can see what i can do to help you fix it

In serverscript:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,id,gun,mouse,point)

In localscript:

game.ReplicatedStorage.RemoteEvent:FireServer(1,char[gun.Name],mouse.Hit.p,gun.FirePoint.Position,lastshot)

this is definitely a tougher issue since that seems like it would work just fine. Is the firePart welded to the gun properly? Check in game by clicking in the explorer on the firePart and see where it is with the move tool (CTRL+2)

Like said in an earlier post, I have checked and the gun firepoint is in the correct position at the tip of the gun as shown:

idk then, it should work fine. do you change the point variable in the server script at all?

After using Ctrl-F to confirm, I do not.

Uh, it suddenly fixed itself. Odd.

2 Likes