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

please help with raycasting?

Asked by 8 years ago

How would Do something so that if the ray touches the player, they die?

local ray = Ray.new(pos.CFrame.p, (endPos - pos.CFrame.p).unit * 300)       
local hit, position = workspace:FindPartOnRay(ray, player.Character)
local distance = (position - pos.CFrame.p).magnitude        
ball.CFrame = CFrame.new(position, pos.CFrame .p) * CFrame.new(0, 0, 1.5) * CFrame.new(0, 0, -distance)     
game.Debris:AddItem(ball, 1)        
local sT = 0            
local bv = Instance.new("BodyVelocity", ball);  
bv.velocity = -ball.CFrame.lookVector * speed

1 answer

Log in to vote
0
Answered by 8 years ago

Hi, seimmaster07! In that script put this code in here -

function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then   -- if a humanoid exists, then
        humanoid.Health = 0 -- damage the humanoid
    end 
end

script.Parent.Touched:connect(onTouch)

Thank you for asking! :D

Ad

Answer this question