please help with raycasting?
How would Do something so that if the ray touches the player, they die?
1 | local ray = Ray.new(pos.CFrame.p, (endPos - pos.CFrame.p).unit * 300 ) |
2 | local hit, position = workspace:FindPartOnRay(ray, player.Character) |
3 | local distance = (position - pos.CFrame.p).magnitude |
4 | ball.CFrame = CFrame.new(position, pos.CFrame .p) * CFrame.new( 0 , 0 , 1.5 ) * CFrame.new( 0 , 0 , -distance) |
5 | game.Debris:AddItem(ball, 1 ) |
7 | local bv = Instance.new( "BodyVelocity" , ball); |
8 | bv.velocity = -ball.CFrame.lookVector * speed |