3027474
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1636 |
|
|
| 24 Jun 2012 05:47 PM |
| How does work and can I change 'character'(if so please tell me what I would replace it with) |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 05:52 PM |
Its a Method of the Service Players (game.Players), it takes 1 argument (unsure if more?), and the argument should be the "Character" of the player, usually the model with the same name as the player located in the Workspace service. xP
game.Players:GetPlayerFromCharacter(workspace.ElectricAxel) --should return game.Players.ElectricAxel |
|
|
| Report Abuse |
|
|
3027474
|
  |
| Joined: 30 Dec 2008 |
| Total Posts: 1636 |
|
|
| 24 Jun 2012 05:56 PM |
| Then whats the point of that? You could just say game.Players.EletricAxel |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 05:58 PM |
When a player touches a brick and you want to get the player, say the Leg, Leg is inside my Character, so you could do:
script.Parent.Touched:connect(function(hit) local player = game.Players:getPlayerFromCharacter(hit.Parent) if player then print(player.Name.. " has touched the objective!") end end) |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:07 PM |
Oh if you really wanted, it could take two arguments.
script.Parent.Touched:connect(function(hit) local player = game.Players.GetPlayerFromCharacter(Game.Players, hit.Parent) if player then print(player.Name.. " has touched the objective!") end end) |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 24 Jun 2012 06:08 PM |
What does that first argument, Game.Players, actually mean?
I assume it can be changed to something else? |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:10 PM |
| When you index the function (.) instead of methodize it (:) then you remove the default given argument. All methods use their calling factor (the thing before the colon) as the first argument. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 24 Jun 2012 06:12 PM |
| I learnded something new todai! Thankee, Mr. NicNac. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 06:15 PM |
| Oh, hai MNN... Uhm always with the outstanding clothes I see... And yes, I guess I did forget about that trick to add 1 unneeded argument. :P |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:16 PM |
Technically I'm not wearing anything but a hat. But ROBLOX doesn't know that.
"1 unneeded argument"
Definitely useless. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 06:17 PM |
lol You could say you are wearing a costume.
You know what I meant, of course it is important, but why not use it as a method instead of a function? |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:19 PM |
| Oh no, I meant literally creating the argument in the raw code. It is useless to not call it as a method. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 06:21 PM |
| What happens if I use the connect from one event as a function and specify another event instead? O-o |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:22 PM |
Than it should do the other event. Like this,
part.Touched.connect(Game.Players.PlayerAdded, function(p) print(p.Name) end) |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 24 Jun 2012 06:25 PM |
| Would that start looking for Players added after the brick is touched, or right off the bat? |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:26 PM |
| The Touched event doesn't even connect. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 24 Jun 2012 06:29 PM |
Oh, derp, didn't read it right. So you could just use connect(event, function) on its own? |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:31 PM |
No. It's like the workspace. A part is in the workspace.
Workspace.Part
To get anything inside that part you have to do
Workspace.Part.Something
The function 'connect' is inside events. I have to use a random event to get that function. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 24 Jun 2012 06:34 PM |
Okay.
Wellp, I learnded something *completely* todai. :D |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 06:38 PM |
| Interesting, thanks. So the connect function is the same for every event. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:39 PM |
| Hopefully, or else I just messed up your grip of the function. |
|
|
| Report Abuse |
|
|
adark
|
  |
| Joined: 13 Jan 2008 |
| Total Posts: 6412 |
|
|
| 24 Jun 2012 06:40 PM |
| MrNicNac, I just have a mind full of [BLEEP] all of the times. Most anything you can say will just shift some stuff around. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 06:40 PM |
| What do you mean hopefully? Aren't you sure of this? xD |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 24 Jun 2012 06:41 PM |
| Well it "should" work. I don't know. I can't try it. |
|
|
| Report Abuse |
|
|
|
| 24 Jun 2012 06:54 PM |
| Oh, I see... I'll test it some day. xP |
|
|
| Report Abuse |
|
|