ToboboT
|
  |
| Joined: 25 Jun 2011 |
| Total Posts: 2385 |
|
|
| 17 Jul 2013 09:12 PM |
I don't always use GetChildren() but when I do I suck at it...
Basically I need help inserting anything in the value loadout basically which are the guns it wont insert them.
function play() local w = script.Parent.Parent.Parent.Parent.WHITEOUT w.BackgroundTransparency = 1 for i = 1,10 do w.BackgroundTransparency = w.BackgroundTransparency - .1 wait(.2) end script.Parent.Parent.Parent.Visible = false spawnplayer() for i = 1,10 do w.BackgroundTransparency = w.BackgroundTransparency + .1 wait(.2) end
-- I checked and then double checked all this. All the places are in the correct place. I think it is the for o,weps thingy. HELP
local loadout = script.Parent.Parent.Parent.Parent.Parent.Parent.loadout for o, weps in next, weaps do --weps is your table print(weaps) weaps.Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Backpack
end end |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2013 09:16 PM |
| Where is the variable 'weaps' defined? If that's the whole code, then it isn't defined anywhere and it isn't surprising your code doesn't work. |
|
|
| Report Abuse |
|
|
ToboboT
|
  |
| Joined: 25 Jun 2011 |
| Total Posts: 2385 |
|
|
| 17 Jul 2013 09:20 PM |
Heres the whole script:
function spawnplayer() if game.Players.Playing.Value == true then local p = script.Parent.Parent.Parent.Parent.Parent.Parent if p.TeamColor == BrickColor.new("Bright blue") then p.Character.Torso.CFrame = CFrame.new(game.Workspace.bs1.CFrame.p or game.Workspace.bs2.CFrame.p) elseif p.TeamColor == BrickColor.new("Bright red") then p.Character.Torso.CFrame = CFrame.new(game.Workspace.rs1.CFrame.p or game.Workspace.rs2.CFrame.p) end end end
function play() local w = script.Parent.Parent.Parent.Parent.WHITEOUT w.BackgroundTransparency = 1 for i = 1,10 do w.BackgroundTransparency = w.BackgroundTransparency - .1 wait(.2) end script.Parent.Parent.Parent.Visible = false spawnplayer() for i = 1,10 do w.BackgroundTransparency = w.BackgroundTransparency + .1 wait(.2) end local loadout = script.Parent.Parent.Parent.Parent.Parent.Parent.loadout for o, weps in next, weaps do --weps is your table print(weaps) weaps.Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Backpack end end
local a = script.Parent.Box
script.Parent.MouseEnter:connect(function() a.Visible = true end)
script.Parent.MouseLeave:connect(function() a.Visible = false end)
script.Parent.MouseButton1Down:connect(function() if game.Players.Playing.Value == true then play() end end) |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2013 09:23 PM |
| Where are the guns you want to insert located? Right now, your code basically tries to get them out of nowhere, which doesn't make sense. |
|
|
| Report Abuse |
|
|
StudioAD
|
  |
| Joined: 14 Jul 2013 |
| Total Posts: 9 |
|
| |
|
ToboboT
|
  |
| Joined: 25 Jun 2011 |
| Total Posts: 2385 |
|
|
| 17 Jul 2013 09:27 PM |
I double and then triple checked where the script is getting the guns. If you want a breakdown heres how it goes:
script> play> buttons> MainFrame> Menu> PlayerGui> Player> loadout> guns
It is a NumberValue in the player inserted every time PlayerAdded and I am sure. I think I need help with the for and do statement |
|
|
| Report Abuse |
|
|
StudioAD
|
  |
| Joined: 14 Jul 2013 |
| Total Posts: 9 |
|
| |
|
ToboboT
|
  |
| Joined: 25 Jun 2011 |
| Total Posts: 2385 |
|
| |
|
|
| 17 Jul 2013 09:43 PM |
I've cleaned up the code a bit, and I might or might not have fixed the issue, depending on where the guns are actually located. You say `loadout` is a NumberValue, but if it's a NumberValue, where are the guns?
local Players = Game:GetService('Players') local player = script.Parent.Parent.Parent.Parent.Parent.Parent
function spawnplayer() if game.Players.Playing.Value then if player.TeamColor == BrickColor.new('Bright blue') then player.Character.Torso.CFrame = CFrame.new(Workspace.bs1.CFrame.p or Workspace.bs2.CFrame.p) elseif player.TeamColor == BrickColor.new('Bright red') then player.Character.Torso.CFrame = CFrame.new(Workspace.rs1.CFrame.p or Workspace.rs2.CFrame.p) end end end
function play() local w = script.Parent.Parent.Parent.Parent.WHITEOUT for background_transparency = 1, 0, -.1 do w.BackgroundTransparency = background_transparency wait(.2) end script.Parent.Parent.Parent.Visible = false spawnplayer() for background_transparency = 0, 1, .1 do w.BackgroundTransparency = background_transparency wait(.2) end local loadout = script.Parent.Parent.Parent.Parent.Parent.Parent.loadout local weapons = loadout -- Are the guns located there? for _, weapon in next, weapons:GetChildren() do weapon.Parent = script.Parent.Parent.Parent.Parent.Parent.Parent.Backpack end end
local box = script.Parent.Box
script.Parent.MouseEnter:connect(function() box.Visible = true end)
script.Parent.MouseLeave:connect(function() box.Visible = false end)
script.Parent.MouseButton1Down:connect(function() if Players.Playing.Value then play() end end) |
|
|
| Report Abuse |
|
|