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
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