|
| 03 Dec 2013 03:02 PM |
Okay, so, I have been unsuccessful to find out what arguments are and how to refer to the clicker or toucher of a GUI or brick. Can anybody explain in a short lesson or give me a link to a wiki page or video? An example would be:
function onClick() --I think this is where the argument goes, what is it? .Humanoid.Health = 0 -- Referring to the clicker? end
script.Parent.Touched:connect(onClick)
Thx. I know this may have errors, and I am nooby, but I still need help. :/ |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 03 Dec 2013 03:04 PM |
function onClick(player) workspace:findFirstChild(player.Name).Humanoid.Health = end |
|
|
| Report Abuse |
|
|
| |
|
| |
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 03 Dec 2013 03:48 PM |
Put this in any TextButton:
-- function onClick(player) workspace:findFirstChild(player.Name).Humanoid.Health = 0 end script.Parent.MouseButton1Up:connect(onClick) -- |
|
|
| Report Abuse |
|
|
|
| 03 Dec 2013 07:24 PM |
| No, thx, but I need to know how to do it FREELY, and by myself. |
|
|
| Report Abuse |
|
|
integrand
|
  |
| Joined: 30 Nov 2013 |
| Total Posts: 42 |
|
|
| 03 Dec 2013 07:24 PM |
/フフ ム`ヽ / ノ) ∧__∧ ) ヽ / | (´・ω ・`)ノ⌒(ゝ._,ノ / ノ⌒7⌒ヽーく \ / 丶_ ノ ノ、 |/ `ヽ `ー-‘_人`ー |
|
|
| Report Abuse |
|
|
robomax11
|
  |
| Joined: 07 Jul 2011 |
| Total Posts: 6828 |
|
|
| 03 Dec 2013 07:26 PM |
@above gtfo troll
any okay, dude this is how u do it
MouseButton1Down() is when a player pushes down the left mouse |
|
|
| Report Abuse |
|
|
| |
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 04 Dec 2013 11:20 AM |
| What do you mean by 'freely and by yourself'? |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2013 03:32 PM |
| Like, if I want to script myself. I mean, I don't wanna be limited. I want to have it in my OWN mind. Anybody have ANYTHING? :C |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 04 Dec 2013 03:45 PM |
An argument is the value you supply when you call a function. A parameter is the variable defined in the parenthesis when a function is defined.
function func(param1,param2) -- these two things in parenthesis are variables that will stand for whatever you call the function with return param1+param2 end
--calling the function func(7,3) -- you can enter any kind of value or defined variable in the parenthesis when calling a function
now, when you call the function it pretends like this is the code
local param1=7 local param2=3
and executes the rest of the chunk from there
make sense? |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 04 Dec 2013 04:01 PM |
when you connect a function with an event, the event simply calls the function when it fires, and the arguments given depend on the event. For touched, a part is returned.
function touchd(par) print(par.Name) end workspace.Part.Touched:connect(touchd) |
|
|
| Report Abuse |
|
|
| |
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 04 Dec 2013 04:16 PM |
| Don't help this kid, he has no idea what he is doing. |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 04 Dec 2013 04:33 PM |
lets break it down
the Touched event returns a part. The part that touched whatever the event is called on, right? just go with it
local part=workspace.Part -- defining the part
local touching=part.Touched:wait() --the wait method is simple, a lot like connect --it returns the parameters of an event when it's fired, only ONCE
-- Now, this is where we call the function onTouch(touching)
function onTouch(brick) -- defining the function, and the 'brick' parameter print(brick.Name) -- inside this function, brick is equal to 'touching' -- >> does it make sense how brick == touching right here? << end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Dec 2013 04:37 PM |
smiley, you also have no idea what you are doing.
"function onClick(player) workspace:findFirstChild(player.Name).Humanoid.Health = 0 end script.Parent.MouseButton1Up:connect(onClick)" TextButtons's MouseButton1Down/Click/Up events don't return anything, and he obviously wants it in a ClickDetector |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 04 Dec 2013 04:40 PM |
oh I didn't notice he wanted it in ClickDetector form too
local PlayerClicked=workspace.Part.ClickDetector.Clicked:wait() -- clicked returns the player that clicked a clickDetector PlayerClicked.Character:BreakJoints() |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Dec 2013 04:42 PM |
^ That's only going to work once, plus there is an error, do this
while true do local playerClicked = workspace.Part.ClickDetector.MouseClick:wait() playerClicked.Character:BreakJoints() end
or do this:
workspace.Part.ClickDetector.MouseClick:connect(function(playerClicked) playerClicked.Character:BreakJoints() end) |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 04 Dec 2013 04:44 PM |
| You're not helping the OP, cnt, and don't think you know something I don't about what I posted. You can act like a know-it-all in Scripters if you'd like. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Dec 2013 04:45 PM |
You obviously don't know the ClickDetectors's event if you think "local PlayerClicked=workspace.Part.ClickDetector.Clicked:wait()" is right
And I don't act like a know it all, your small brain might interpret it as that but that's not my problem |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Dec 2013 04:48 PM |
| Why would I cry? You obviously have no idea what causes crying, and why would I cry over anything to my "mommy" |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 04 Dec 2013 04:50 PM |
| HEY HEY! Stop! We're supposed to help people! Not argue with everyone who does! You both have the satisfaction that you're better than me, if that helps O3o |
|
|
| Report Abuse |
|
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 04 Dec 2013 04:50 PM |
| I guess your pride makes it okay for you to keep posting useless, unproductive comments in your mind. Whatever makes you happy, eh? |
|
|
| Report Abuse |
|
|