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

Tool on touch parenting service?

Alright so i have an issue. I have a baseball that when thrown will become a child of the workspace. What I want to do is when the baseball is a homerun, it will trigger a message with the person who hit it. I have all of that done except the part with the players name. I don't know how to get the players name who hit it because the parent of the baseball is the workspace.

debounce = false

function onTouched(hit)
local player = --this is where i need help
if hit.Name == "Ball" and debounce == false then
debounce = true
local h = Instance.new("Message")
h.Parent = hit.Parent
h.Text = "Home run hit by"..player.Name
wait(4)
h.Parent = game.Workspace
h:remove()
debounce = false
end
end

script.Parent.Touched:Connect(onTouched)

1 answer

NAME_PLAYER the name of the player

for i, child in pairs(game.Workspace:GetChildren())
	if child:IsA("Model") and child.Name == "NAME_PLAYER"  then

	end
end

1 comment

0

This isn't want i meant, if I could easily name the player localplayer but that when the message would appear, it would name yourself not the player who hit the hr.

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