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

Help with ontouched?

I'm making a deathray script where if you aren't touching a certain block, you freeze. How would I tell if a players torso is touching a block?

function StoneRay()
for _, player in pairs(game.Players:GetPlayers())do
	local torso = player.Character:FindFirstChild("Torso")
	--help please
		
	
end
end

1 comment

0

also upvote me pls

1 answer

✓ Accepted answer

You can use the Touched and TouchEnded event. Here's an example.

script.Parent.Touched:connect(function(hit)
--Touching code here
Touch=true
end)

script.Parent.TouchEnded:connect(function(hit)
--Touching code here
Touch=false
end)

I hope this helped!

**EDIT:**Credit to UserOnly20Characters for his reminding me to fix some errors.

~Chem

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