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

How do I check if the player touched a brick?

Asked by 10 years ago

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

Log in to vote
0
Answered by
Exsius 162
10 years ago

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)

Ad
Log in to vote
-1
Answered by
Qorm 100
10 years ago
function onTouch(hit)
--your stuff--
end
Part.Touched:connect(onTouch)
if Part.hit then
print("you hit it")
end

this should work

Answer this question