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

Help with ontouched?

Asked by 9 years ago

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
0
also upvote me pls ChemicalHex 979 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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

Ad

Answer this question