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

Whats the function for touching a block? [HELP]

Asked by
OFF_S4LE 127
4 years ago

By function I mean something like mousebutton1down(function()

3 answers

Log in to vote
0
Answered by
N33H 19
4 years ago
Edited 4 years ago
local part = script.Parent
local touched = false

part.Touched:connect(function()
    touched = true
    --put script to execute here
end)
0
Db THUNDER_WOW 203 — 4y
0
Db THUNDER_WOW 203 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Add a click detector and it should be something like liked or mousebuttondown. Roblox should tell you when you script it though.

0
By touching I mean how would a script tell if a player is touching a part? OFF_S4LE 127 — 4y
Log in to vote
0
Answered by 4 years ago

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.

Answer this question