maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 12 Mar 2014 08:46 PM |
player = script.Parent classes = script:GetChildren ()
function CheckClass () for i,v in pairs (classes) do if v.Value then class = v end end end
player.CharacterAdded:connect (function () CheckClass () if player.TeamColor == BrickColor.new ('Cyan') then game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack end end)
It's a loadout saver in an FPS (i.e. if you have the sniper class and die, you will still spawn with sniper tools).
classes is a set of BoolValues, each having the name of a class (hideous method, I know. This is the one that came to mind, though).
The script gives no errors, but doesn't distribute the tools after I die, either. |
|
|
| Report Abuse |
|
|
jonesj627
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 12 Mar 2014 08:48 PM |
function CheckClass () for i,v in pairs (classes) do if v.Value then class = v end end end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect (function () CheckClass () if player.TeamColor == BrickColor.new ('Cyan') then game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack end end) end)
--its good to be batman |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 12 Mar 2014 08:49 PM |
| Is that really necessary when you have a script inside the player? |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
| |
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 13 Mar 2014 03:10 PM |
Guys, I think the problem is either here:
class = v
or here:
game.ServerStorage.Allies[class]:Clone () |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 13 Mar 2014 03:25 PM |
| This is just syntax. I need to know the proper syntax. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
| |
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 13 Mar 2014 03:52 PM |
| This is a real stump. I mean this is my only job ATM, and it doesn't even work. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 13 Mar 2014 03:55 PM |
player = script.Parent classes = script:GetChildren ()
function CheckClass () for i,v in pairs (classes) do if v.Value then class = v.Name --Ummmm XD end end end
player.CharacterAdded:connect (function () CheckClass () if player.TeamColor == BrickColor.new ('Cyan') then game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack end end) |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 13 Mar 2014 03:58 PM |
Tried that too already. I made this change however, so I'll include it with that change:
player = script.Parent classes = script:GetChildren ()
function CheckClass () for i,v in pairs (classes) do if v.Value then class = v.Name --this is incorporating the change. end end end
player.CharacterAdded:connect (function () CheckClass () if player.TeamColor == BrickColor.new ('Cyan') then stuff = game.ServerStorage.Classes.IF[class]:GetChildren () stuff:Clone ().Parent = player.Backpack else stuff = game.ServerStorage.Classes.Allies[class]:GetChildren () stuff:Clone ().Parent = player.Backpack end end) |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 13 Mar 2014 04:09 PM |
Not even this works:
if player.TeamColor == BrickColor.new ('Cyan') then stuff = game.ServerStorage.Classes.IF.Assault:GetChildren () -- [class]:GetChildren () stuff:Clone ().Parent = player.Backpack else stuff = game.ServerStorage.Classes.Allies.Assault:GetChildren () -- [class]:GetChildren () stuff:Clone ().Parent = player.Backpack end end) |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 13 Mar 2014 04:37 PM |
:GetChildren() is a table -.- for i, v loop it. |
|
|
| Report Abuse |
|
|
|
| 13 Mar 2014 04:39 PM |
Erm..does ANYONE realize you can't run a script inside game.Players.Playername? U can have a LocalScript in StarterGui,or StarterPack |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
| |
|
|
| 13 Mar 2014 04:56 PM |
just to test,go into server/or test solo and insert a localscript into the player that says
p = script.Parent print (p.Name)
there will be NO output.. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 13 Mar 2014 04:58 PM |
Huh, wonder why that is... Could you have it in StarterGear? |
|
|
| Report Abuse |
|
|
|
| 13 Mar 2014 05:03 PM |
StarterGear?Don't you mean StarterPack?
StarterPack and StarterGui work:)
Just define player as game.Players.LocalPlayer And have it as a localscript |
|
|
| Report Abuse |
|
|
7y13rb
|
  |
| Joined: 28 May 2011 |
| Total Posts: 223 |
|
|
| 13 Mar 2014 05:06 PM |
--er.....shouldn't you need a wait also? if they respawn after it gives the tools --it kinda defeats the purpose...also another way to do this: --1-put the script in the tool itself(trust me) --2-put tool in starterpack --3-in the script: local player = script.Parent.Parent.Parent:GetPlayerFromCharacter() if player.TeamColor ~= "TEAMCOLORHERE" then --if they aren't on a team script.Parent:Destroy() --Killcode end --basically it gives it to everyone, then if they aren't on a specific team, it --destroys it. |
|
|
| Report Abuse |
|
|
7y13rb
|
  |
| Joined: 28 May 2011 |
| Total Posts: 223 |
|
|
| 13 Mar 2014 05:07 PM |
| You might need to change script i gave...i don't know where TeamColor is...i think its in player though |
|
|
| Report Abuse |
|
|
|
| 13 Mar 2014 05:09 PM |
Btw,GetChildren() returns a table.. U have to use a for loop |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 13 Mar 2014 06:09 PM |
@7yrb, sorry. Not what I'm looking for.
@Island, I do have the for loop now. If you put it in the StarterPack, do you need to have a script that distributes it? |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
| |
|
roleo1122
|
  |
| Joined: 28 Jan 2013 |
| Total Posts: 971 |
|
|
| 13 Mar 2014 07:27 PM |
function CheckClass () for i,v in pairs (classes) do if v.Value then class = v end end end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect (function () CheckClass () if player.TeamColor == BrickColor.new ('Cyan') then game.ServerStorage.Classes.IF[class]:Clone ().Parent = player.Backpack else game.ServerStorage.Classes.Allies[class]:Clone ().Parent = player.Backpack player.backpack[class] end end) end)
|
|
|
| Report Abuse |
|
|