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

Make an event fire when a player touched another player?

As it says in the title, how does one make an event fire when one player touches another player. Something like in freeze tag, infection or hide and seek. I've thought of various methods, but none of them worked. Could someone help me with it? I'm not asking for a whole script, just a fragment, which will fire the event.

1 answer

✓ Accepted answer

We can used the touched event and the GetPlayerFromCharacter() method to find the player.

local player = PLAYER --Reference player here.
local character = player.Character

character.Torso.Touched:connect(function(hit)
local tagged = game.Players:GetPlayerFromCharacter(hit.Parent)
if tagged then
print(player.Name.." tagged "..tagged.Name.."!")
end
end)

4 comments

0

Or, hit.Parent.Name would also work.

0

Thanks a bunch :D

0

No problem.

0

Lord, you can change the name of the Characters model. Additionally, being able to access the actual player is always a plus in almost any case. @ Viva, if this post helped you, please hit the "Solved" button so others can learn from this!

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