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

Simple touched function? [solved]

Asked by
iCroga 5
10 years ago

Hello, I'm new to scripting, could anyone help me with a touched function?

1function touchies()
2--bunch of stuff you don't need to know about
3end
4script.Parent:Touch(touchies)

1 answer

Log in to vote
3
Answered by 10 years ago

Line 4 is the problem, you put :Touch You need to put, .Touched:connect So here is the fixed script:

1function touchies()
2--stuff
3end
4script.Parent.Touched:connect(touchies)

And if you didn't know, there is an alternative way. Put line 4 into line 1 and change end to end) Like this:

1script.Parent.Touched:connect(function()
2    --stuff
3end)
0
Thank you! iCroga 5 — 10y
0
Exactly what grenad said. I'd just like to add the fact that the second piece of code that Gren did is called an 'anonymous function'. DigitalVeer 1473 — 10y
0
Wow, I didn't even know that myself. Grenaderade 525 — 10y
Ad

Answer this question