#Raycast returns nil

1 messages · Page 1 of 1 (latest)

narrow plume
#

`function SHOOT()

local DIRECTION = (Vector3.new(MOUSE.Hit.Position) - Vector3.new(WEAPON_RAYCAST_START.Position)) * 5000

local RAY_PARAMETERS = RaycastParams.new()
RAY_PARAMETERS.FilterDescendantsInstances = {PLAYER_CHARACTER, WEAPON_RAYCAST_START}
RAY_PARAMETERS.FilterType = Enum.RaycastFilterType.Exclude

local RAYCAST = workspace:Raycast(WEAPON_RAYCAST_START.Position, DIRECTION, RAY_PARAMETERS)

local RAY_RESULT
if RAYCAST then
    RAY_RESULT = RAYCAST.Instance.Parent
end

local RAY_PLAYER
if RAY_RESULT and RAYCAST then
    if RAY_RESULT:FindFirstChildOfClass("Humanoid") then
        RAY_PLAYER = RAY_RESULT:FindFirstChildOfClass("Humanoid")
        SHOOT_EVENT:FireServer(RAYCAST, RAY_RESULT, RAY_PLAYER)
    end
end
print(RAY_RESULT)

end`

bold kestrel
narrow plume
#

so instead i should use (MOUSE.Hit.Position - WEAPON_RAYCAST_START.Position) * 5000?

narrow plume
#

Aight

#

It works

#

thanks so much man