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

Make an event fire when a player touched another player?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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)
0
Or, hit.Parent.Name would also work. EzraNehemiah_TF2 3552 — 9y
0
Thanks a bunch :D vivaftw 5 — 9y
0
No problem. aquathorn321 858 — 9y
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! DigitalVeer 1473 — 9y
Ad

Answer this question