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

return name of hitter?

If a brick is touch by a player the textlabel of billboard gui will print the name of player. The BillBoardGui is inside the "Head" both head and Script is inside the "Model" Here's my model format +Model ++Script Head +BillBoardGui ++TextLabel I don't know whats wrong to my script..

script.Parent.Touched:connect(function(hit)
s = plr:findFirstChild("Name")
parent.BillBoard.TextLabel .Text = "You have won!"..s

script.Parent.Touched:connect(onTouch)

1 answer

local parent = script.Parent

parent.Touched:connect(function(hit) 
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	local hitterName
	if humanoid ~= nil then
		hitterName = humanoid.Parent.Name
		parent.Billboard.TextLabel.Text = "You have won, "..hitterName.."!"
	end
end)

What the script does is: checks if the object that touched the part has a Humanoid on it's model. If it does, it most likely is a player, so we get the model name.

2 comments

0

It says "Touch is not valid member of model"

0

Weird, what line is the error on?

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