Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

please help with raycasting?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.