RayCasting Issues

  1. What do you want to achieve?
    I want the damage function to work properly

  2. What is the issue?
    Well whenever the script executes the variable part receives an error

  3. What solutions have you tried so far?
    I attempted to change dealer.Character to other parents of dealer.Character, still the same error.

This is the ROBLOX weapons kit I realized quickly that the kit is very exploitable that is when I tried to then fix some of the flaws within it.

local function _defaultDamageCallback(system, target, amount, damageType, dealer, hitInfo, damageData)
    if target:IsA("Humanoid") then
        local RayCheck = Ray.new(dealer.Character.Head.CFrame.Position, target.Parent.HumanoidRootPart.CFrame.Position)
        local Part = workspace:FindPartOnRayWithWhitelist(RayCheck, dealer.Character)
        if string.match(Part:GetFullName(), target.Name) then
              target:TakeDamage(amount)
        elseif target.Name == "Glass" then
            target.Settings.Health.Value = target.Settings.Health.Value - amount
        end
    end
end

:FindPartOnRayWithWhiteList’s second parameter is a table, not an instance.

This should fix it:

workspace:FindPartOnRayWithWhitelist(RayCheck, {dealer.Character})

Yes, thanks should have looked at developer wiki it shows that it is a table, thanks!