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

Ontouch player name finder?

Im developing a hockey game and when someone scores I want to make it so it will say goal scored by (Name) and assisted by (name) and (name) but I dont know how to find the players that last hit the puck.

1 comment

0

Tag it. When the puck is touched, check if it was by a Player Character. If it was, record it. Check the records when your goal is scored.

1 answer

Let me know if this works.

function onTouched(part)
	if part.Parent:FindFirstChild("Humanoid") then
	local name = part.Parent.Name
	print(name) --change this to display the name wherever (GUI, etc.)
end
end

script.Parent.Touched:connect(onTouched)

Put this script inside the part (goal).

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