sycips
|
  |
| Joined: 21 Mar 2011 |
| Total Posts: 1368 |
|
|
| 24 Oct 2011 09:40 AM |
I've got a problem... If you play my game, you finally get some tools. But everyone gets the same tool like: there's a tool in the lighting folder and everyone has to get a copy. My script lines are:
for i,v in pairs(game.Players:GetChildren()) do game.Lighting.Tool:clone().Parent = v.Backpack end
this script works in solo play, but if I do it online no one will get the tool... Does someone know how to give everyone a copy of one tool at the same time and it also does work online in a server?
plz awnser!!!
~sycips~ |
|
|
| Report Abuse |
|
|
Trioxide
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
| |
|
07lchris
|
  |
| Joined: 28 Feb 2010 |
| Total Posts: 1603 |
|
|
| 24 Oct 2011 10:12 AM |
for i,v in pairs(game.Players:GetChildren()) do local T = game.Lighting.Tool:Clone() T.Parent = v.Backpack M_P = Instance.new('Message', game.Workspace) M_P.Text = 'Tool given to '..v.Name end
It depends on where the script is and how you are activating it. Try this and tell me what happens 'online'. |
|
|
| Report Abuse |
|
|
sycips
|
  |
| Joined: 21 Mar 2011 |
| Total Posts: 1368 |
|
|
| 24 Oct 2011 10:46 AM |
| It does work 0_0 but why? I did the same thing, you only put a message in it... |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2011 10:49 AM |
local tools = { -- put your tools here. game.Lighting.Tool, game.Lighting.Tool2, game.Lighting.Tool3 }
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function() for i,v in pairs(tools) do v:clone().Parent = plr.Backpack end end) end) |
|
|
| Report Abuse |
|
|
sycips
|
  |
| Joined: 21 Mar 2011 |
| Total Posts: 1368 |
|
|
| 24 Oct 2011 11:14 AM |
nvm Ik what the real problem was:
I used this:
pls = game.Players:GetChildren()
for i,v in pairs(pls) do end
it should be:
for i,v in pairs(game.Players:GetChildren()) do end
you may not use the shortcut pls... I did that because I used game.Players:GetChildren() many times, like 6 times... |
|
|
| Report Abuse |
|
|
07lchris
|
  |
| Joined: 28 Feb 2010 |
| Total Posts: 1603 |
|
|
| 24 Oct 2011 01:55 PM |
You could always do:
pls = game.Players
for i,v in pairs(pls:GetChildren()) do end
|
|
|
| Report Abuse |
|
|
|
| 24 Oct 2011 02:18 PM |
pls = game.Players:GetChildren() for i,v in pairs(pls) do ... end
for i,v in pairs(game.Players:GetChildren()) do ... end
pls = game.Players for i,v in pairs(pls:GetChildren()) do ... end
All three of those methods will work (the top one gets the table once though, probably as the server starts and there are no players. I don't suggest it)
Anywho, I don't suggest using game.Players:GetChildren() if you want all the players. Using the method :GetPlayers() is a much safer way to get all the players and make sure the script doesn't beak.
Regards, ~Scarfacial |
|
|
| Report Abuse |
|
|
sycips
|
  |
| Joined: 21 Mar 2011 |
| Total Posts: 1368 |
|
|
| 27 Oct 2011 11:35 AM |
| y using getplayers()? the only Object in that folder is a player... Have you ever seen a script in that folder?-_- |
|
|
| Report Abuse |
|
|