Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 07:58 PM |
| It doesn't seem to be working for me.. |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2013 08:00 PM |
Yes but you don't really need it. Just use game.Players.LocalPlayer |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 21 Jun 2013 08:00 PM |
Assuming you're using a LocalScript (which can only run in backpacks or players anyways), you can just do:
player = game.Players.LocalPlayer -- Simple as that, only works in LocalScripts char = player.Character |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 08:13 PM |
| I don't think LocalPlayer will work for what I'm using it for. |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2013 08:14 PM |
| Well if the LocalScript isn't inside the Player then there is no point in using it. |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 21 Jun 2013 08:21 PM |
@perpetual
If you code a weapon that needs to get to the target's Player, then you need GetPlayerFromCharacter.
To the OP, yes it works in a localscript. |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 08:23 PM |
@Swmaniac:
Yes, that's what I'm trying to do. The only issue is, my anti-teamkill function isn't working. Can I use GetPlayerFromCharacter for this method? The output really isn't telling me anything useful. |
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
|
| 21 Jun 2013 08:30 PM |
make sure you are using game:service'Players':GetPlayerFromCharacter()
|
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 08:32 PM |
@btft:
What? I didn't have to use that when I used GetPlayerFromCharacter before.. |
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
|
| 21 Jun 2013 08:33 PM |
I mean. make sure you are using game.Players:GetPlayerFromCharacter().
meaning game.Players. |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 08:50 PM |
This is what I have:
b.Touched:connect(function(hit) if hit then if hit.Parent:findFirstChild("Humanoid") then if hit.Parent ~= script.Parent.Parent.Parent then character = hit.Parent player = game.Players:GetPlayerFromCharacter(character) if player.TeamColor ~= script.Parent.Parent.Parent.TeamColor then local human = hit.Parent:findFirstChild("Humanoid") human.Health = human.Health - math.random(10, 15) end end end end end) end script.Parent.Parent.Equipped:connect(function(m) m.Button1Down:connect(onButton1Down) end)
This works up until I put the TeamColor part in. For some reason that breaks the entire script. What am I doing wrong here? This is a LocalScript inside a Part, Inside a Tool, inside a Player's Backpack. |
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
|
| 21 Jun 2013 08:53 PM |
Make sure script.Parent.Parent.Parent.TeamColor is a BrickColor Value. and,
script.Parent.Parent.Parent.TeamColor is what? |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 08:55 PM |
| script.Parent.Parent.Parent.Parent.TeamColor is the Character's TeamColor that is holding the tool. And yes, it should be a BrickColor Value, as long as TeamColors are BrickColor Values. |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2013 08:56 PM |
| No it's not because when the player is holding the tool it goes into the Character. It's no longer in the backpack so that wouldn't work. |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 08:58 PM |
@Perpetual:
I accounted for that. |
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
|
| 21 Jun 2013 08:59 PM |
| Characters don't have a teamcolor Value. |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 21 Jun 2013 09:05 PM |
@Btft:
Derp I meant Player. This:
http://wiki.roblox.com/index.php/RBX.lua.Player_(Object) |
|
|
| Report Abuse |
|
|
btft
|
  |
| Joined: 19 Feb 2011 |
| Total Posts: 1512 |
|
|
| 21 Jun 2013 09:07 PM |
if player.TeamColor ~= game.Players.LocalPlayer.TeamColor then ?? |
|
|
| Report Abuse |
|
|
Zkiller11
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 2914 |
|
|
| 22 Jun 2013 09:02 PM |
@Btft:
That fixed it!! Thanks!! I had been working on that, trying to figure it out for quite a while, it really had me confused. Thanks again all! |
|
|
| Report Abuse |
|
|