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

How do I check if the player touched a brick?

I have looked through the Player API in the wiki and I didn't find anything to do with this. I was wondering if you could detect if someone touched a brick. Is this even possible? If it is could you explain it to me? Due to confusion this is basically what I would want if I wanted this script.

-- NOT THIS
part.Touched:connect(function()
	print("Hi!")
end)

-- I need something like this
game.Players.PlayerAdded:connect(function(player)
	player.Touched:connect(function() -- I would want something like this where it checks to see if the player touched it (and yes I know that player.Touched is not a real thing)
	print("Hi!")
	end)
end)

2 answers

If you are talking about a script that works when you touch a brick

script.Parent.Touched:connect(OnTouch)

if you want it to show you touched it

varTouched = false

function OnTouch(Part)

varTouched = true

wait(0.5)

print ("" ..varTouched.. "")

end
script.Parent.Touched:connect(OnTouch)

function onTouch(hit)
--your stuff--
end
Part.Touched:connect(onTouch)
if Part.hit then
print("you hit it")
end

this should work

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