Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 03 Jul 2012 02:50 AM |
This is something I've done plenty of times before, but all of a sudden I can't seem to make it work.
Related Code:
script.Parent.Touched:connect(function(hit) player = game.Players:getPlayerFromCharacter(hit.Parent) if game:GetService('BadgeService'):UserHasBadge(player.userId, shirtID) then end end)
Is hit.Parent the wrong way to get the character? |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 03 Jul 2012 02:52 AM |
script.Parent.Touched:connect(function(hit) player = game.Players:GetPlayerFromCharacter(hit.Parent) if game:GetService('BadgeService'):UserHasBadge(player.userId, shirtID) then --Where's shirtID defined? end end)
|
|
|
| Report Abuse |
|
|
dddylan98
|
  |
| Joined: 16 Jul 2008 |
| Total Posts: 1497 |
|
|
| 03 Jul 2012 02:52 AM |
| Why not use :findFirstChild(hit.Parent) instead of :getPlayerFromCharacter |
|
|
| Report Abuse |
|
|
Sehnsucht
|
  |
| Joined: 10 Apr 2011 |
| Total Posts: 990 |
|
|
| 03 Jul 2012 02:52 AM |
| I would add a check to make sure 'hit.Parent' isn't anything else that may touch the part, causing the script to break. |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 03 Jul 2012 02:53 AM |
| Because it's normal using :GetPlayerFromCharacter(). |
|
|
| Report Abuse |
|
|
wazup07
|
  |
| Joined: 17 Oct 2009 |
| Total Posts: 313 |
|
|
| 03 Jul 2012 02:55 AM |
| Capitalize Get. GetPlayerFromCharacter() that should work. |
|
|
| Report Abuse |
|
|
wazup07
|
  |
| Joined: 17 Oct 2009 |
| Total Posts: 313 |
|
|
| 03 Jul 2012 02:56 AM |
| guess i was a little late.... -_- |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 03 Jul 2012 02:56 AM |
| I already did that in my correction. |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 03 Jul 2012 02:56 AM |
Maybe...
ALL HAIL THE FLOODCHECK! |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 03 Jul 2012 02:57 AM |
Oh, shirtID was defined as the first line. The output error was "attempting to index global player (a nil value).
Also, I need to check the asset of a player, so I need to get the player, not the humanoid (why are you suggesting findFirstChild? Am i missing something?) |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 03 Jul 2012 02:59 AM |
About ShirtID, that's what I wrote in my correction.
About the asset of the player, I don't think a model with a humanoid inside will ever touch your brick there, that's why people mostly check for a humanoid.
About :findFirstChild() (guess what? :FindFirstChild() works aswell), just forget that. |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 03 Jul 2012 03:02 AM |
"About ShirtID, that's what I wrote in my correction." That is why I addressed it.
"About the asset of the player, I don't think a model with a humanoid inside will ever touch your brick there, that's why people mostly check for a humanoid." Not sure what you are trying to explain there, but thank you for the help.
"About :findFirstChild() (guess what? :FindFirstChild() works aswell), just forget that." I prefer the lower case, but I'll probably use it with capital letters from now on. |
|
|
| Report Abuse |
|
|
Cheater
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 5258 |
|
|
| 03 Jul 2012 03:05 AM |
| It doesn't matter. :findFirstChild() is for old users. |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 03 Jul 2012 03:08 AM |
| Now the script only works once. I'm confused. xD |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 03 Jul 2012 03:11 AM |
| Nevermind it was breaking because non-players were touching it and i forgot to check that |
|
|
| Report Abuse |
|
|
Kelvin98
|
  |
| Joined: 14 Dec 2008 |
| Total Posts: 272 |
|
|
| 03 Jul 2012 04:40 AM |
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") ~= nil then player = game.Players:getPlayerFromCharacter(hit.Parent) if game:GetService('BadgeService'):UserHasBadge(player.userId, shirtID) then end end end) |
|
|
| Report Abuse |
|
|