By function I mean something like mousebutton1down(function()
✓ ANSWER ACCEPTED
Whats the function for touching a block? [HELP]
3 answers
✓ Accepted answer
local part = script.Parent
local touched = false
part.Touched:connect(function()
touched = true
--put script to execute here
end)
Add a click detector and it should be something like liked or mousebuttondown. Roblox should tell you when you script it though.
1 comment
0
By touching I mean how would a script tell if a player is touching a part?
BasePart.Touched Returns: Instance (The part that touched it)
part.Touched:Connect(function(hit)
print(hit.Name)
end)
Be cautious when using this event for multi-part things. For example, if the player were to touch a part that has a '.Touched' listener, it will call the function for each part that touched. You will need to check conditionals (if statements) to prevent this.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Db
Db