Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to work the OnTouch function?

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

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

3 comments

0

Oh. Thanks that will help a lot. :D

0

no problem

0

press the accept answer button and we will both get a point!

This discussion is preserved as it was. New answers, comments, and votes are closed.