By function I mean something like mousebutton1down(function()
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.
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.