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

How do you make a button that executes scripts on touch?

Asked by
iHavoc101 127
4 years ago

Im trying to make a pad, and if your character touches it, it executes a script.

1 answer

Log in to vote
0
Answered by
Nanomatics 1160 Moderation Voter
4 years ago

You can use the .Touched method of a BasePart (touchpad) in order to execute a piece of code when that BasePart is touched.

Example:

local part = workspace.Touchpad

part.Touched:Connect(function(hit)
    if hit and hit.Parent:FindFirstChild("Humanoid") then -- check if part is a character
        --execute code here 
    end
end)

Hope I helped. If you have any questions please let me know.

0
Thanks iHavoc101 127 — 4y
Ad

Answer this question