klamman
|
  |
| Joined: 06 Feb 2010 |
| Total Posts: 436 |
|
|
| 08 Jul 2015 12:32 AM |
function onTouched(msg) a = Instance.new("Message", game.Workspace) a.Text = msg wait(5) a:Remove() end
script.Parent.Touched:connect(onTouched("Hello!"))
I'm relatively new to scripting, and I've been reading a lot on the wiki, but there are still a few scripts that I can't wrap my head around first. Can someone help me? Why does my function in this script fire without the Touched event firing (being fulfilled?)? (Hopefully that was syntactically correct) Thanks in advance. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2015 12:32 AM |
| Why does my mom smell like crap? Maybe I crapped on here. But I Really didn't. Maybe she crapped on her self. |
|
|
| Report Abuse |
|
|
klamman
|
  |
| Joined: 06 Feb 2010 |
| Total Posts: 436 |
|
|
| 08 Jul 2015 12:35 AM |
Essentially, what I'd like to do is make this script
function onTouched() a = Instance.new("Message", game.Workspace) a.Text = "Hello World!" wait(5) a:Remove() end
script.Parent.Touched:connect(onTouched)
accept parameters. Obviously, I'm doing something wrong (as shown by my script above.) |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Jul 2015 12:36 AM |
You'd need to instantiate a separate function to handle the variable distribution.
function onTouched(msg) a = Instance.new("Message", game.Workspace) a.Text = msg wait(5) a:Remove() end
script.Parent.Touched:connect(function() onTouched("Hello!"); end)
Current Date; July 7th 2015, 10:36:45 pm |
|
|
| Report Abuse |
|
|
| |
|
klamman
|
  |
| Joined: 06 Feb 2010 |
| Total Posts: 436 |
|
|
| 08 Jul 2015 12:43 AM |
Thanks KOTwarrior, I really appreciate the help. I'm having a bit of trouble wrapping my head around the last bit. (function() onTouched("Hello!"); What exactly is going on here? The second part is connecting the event to the onTouched function and entering an argument, I get that. But where does "function()" come from? What exactly does it do? I apologize if I'm being too vague. Thanks in advance. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2015 12:43 AM |
| NOTICE ME TOO you ugly looking pancake fuqqin mother fuqer |
|
|
| Report Abuse |
|
|
klamman
|
  |
| Joined: 06 Feb 2010 |
| Total Posts: 436 |
|
|
| 08 Jul 2015 12:46 AM |
@someonedie, Thanks for the help on the earlier thread, but I was actually looking for assistance with a different part of the script. |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Jul 2015 12:50 AM |
| What a waste of a 2011 account. The person behind the screen of that account has probably stole everything from the account ready and is ready to dispose of it. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 08 Jul 2015 01:00 AM |
script.Parent.Touched -- Touched is an event
You can "connect" functions to events so the function will be fired when the event "fires".
script.Parent.Touched:connect(function to connect here)
But this method does not allow you to pass custom arguments, only default event arguments.
So instead you make a function connected to the event that will fire the other function with the argument(s) you want.
script.Parent.Touched:connect(function() onTouched("stuff") end)
-- This is all from my phone so XD |
|
|
| Report Abuse |
|
|