Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ray.new() not detecting hit of player?

Asked by 6 years ago
Edited 6 years ago

Issue
Not Giving Out Any Errors, Just Not Dealing Damage On Hit

Code

This is the section that called the ray

(Loadout.Current Is The Player's Weapon) (gunset is a module script, and damage is set to 10)

local muzzle = loadout.current.Muzzle
local ray = Ray.new(muzzle.CFrame.p,muzzle.CFrame.lookVector*999)
local hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{ c})

    if hit then

        if hit.Parent:FindFirstChild("Humanoid") then
            hit.Parent.Humanoid:TakeDamage(gunset.damage)
        else

            local bh = storage.GunEffects.BulletHole:Clone()
            bh.Parent = workspace
            bh.CFrame = CFrame.new(pos)
            game.Debris:AddItem(bh,1) -- remove bullet hole in 1 second
            delay(0,function()
                for i = 0,1,.1 do   
                    bh.Transparency = i -- make it fade out
                    rs:wait()
                end
            end)            


        end         
    end         

Full Code

Answer this question