#raycasts only detects parts when it exits them???

1 messages · Page 1 of 1 (latest)

hazy jetty
#

so when the part is travelling, it only detects parts when coming out of them for some reason.
this whats prolly the only important part of the code, but i'll give more of it if needed

local function Raycast(SpearCFrame: CFrame, TravelDirection)
    -- checking for hits
    
    local RayResult = workspace:Raycast(SpearCFrame.Position, TravelDirection * RayDistance, RayParams)

    if RayResult and RayResult.Instance then

        local RayHit = RayResult.Instance
        warn(RayHit)
        local RayPos = RayResult.Position
        warn(RayPos)

        local posPart = Instance.new("Part", workspace)
        posPart.Anchored = true
        posPart.Shape = Enum.PartType.Ball
        posPart.Size = Vector3.new(3, 3, 3)
        posPart.CanCollide = false
        posPart.Color = Color3.fromRGB(0, 255, 0)
        posPart.Position = RayPos
        
        return RayPos, RayHit
    end

    return
        
end