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

How to work the OnTouch function?

Asked by 10 years ago

I do not understand this function. I have tried multiple things.

An example of what I have attempted would be:

function OnTouch

script.Parent.Part:Touched(OnTouch)

Which did not work. Could someone explain what I did wrong and explain the code to me?

1 answer

Log in to vote
0
Answered by 10 years ago

You are missing what the function is supposed to do.

function OnTouch() --now the function has a meaning and will work
print("Works!")
end

script.Parent.Part.Touched:connect(OnTouch)

on line five you said script.Parent.Part:Touched(OnTouch) you dont do Part:Touched you do Part.Touched you move the ":" behind the event and add "connect" like this Part.Touched:connect

0
Oh. Thanks that will help a lot. :D Clubb12 0 — 10y
0
no problem CaptainRuno 40 — 10y
0
press the accept answer button and we will both get a point! CaptainRuno 40 — 10y
Ad

Answer this question