tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 28 Jun 2014 10:56 PM |
function OnClicked() wait (5) spawns = {"1","2","3","4"} --Names of the bricks that are used for spawns spawn = spawns[math.random(1,#spawns)] if game.Workspace:findFirstChild(Map1) then actual = game.Workspace.Map1:findFirstChild(spawn) else if game.Workspace:findFirstChild(Map2) then actual = game.Workspace.Map2:findFirstChild(spawn) else if game.Workspace:findFirstChild(Map3) then actual = game.Workspace.Map3:findFirstChild(spawn) end end end game.Players.LocalPlayer.Character.Torso.CFrame = Workspace[math.random(4)].CFrame -- teleports person from neutral spawn to whatever your spawns are set to. end script.Parent.Main.Assault.MouseButton1Up:connect(OnClicked) script.Parent.Main.Commando.MouseButton1Up:connect(OnClicked) script.Parent.Main.Sniper.MouseButton1Up:connect(OnClicked) script.Parent.Main.Scout.MouseButton1Up:connect(OnClicked) script.Parent.Main.Demolition.MouseButton1Up:connect(OnClicked)
Notes for forum if game.Workspace:findFirstChild(Map1) then actual = game.Workspace.Map1:findFirstChild(spawn) else if game.Workspace:findFirstChild(Map2) then actual = game.Workspace.Map2:findFirstChild(spawn) else if game.Workspace:findFirstChild(Map3) then actual = game.Workspace.Map3:findFirstChild(spawn) end end this is the part that is broken the idea is to have my script search for which map it is then pickup the spawns inside of the map to send players to |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
| |
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 28 Jun 2014 11:24 PM |
| Does no one help in this forum anymore? |
|
|
| Report Abuse |
|
|
|
| 29 Jun 2014 12:07 AM |
The function FindFirstChild requires a string, and you've passed it a literal value, which I think is "nil".
Also, use elseif statements instead of those broken if and then else blocks. |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 29 Jun 2014 12:17 AM |
Well I had an elseif statement but it didn't work either.
function FindSpawns () if workspace:findFirstChild("Map1") then local spawns spawns = workspace.Map1:GetChildren() else if (workspace:findFirstChild("Map2")) then local spawns = {} spawns2 = workspace.Map2:GetChildren() else if (workspace:findFirstChild("Map3")) then local spawns = {} spawns2 = workspace.Map3:GetChildren() end
|
|
|
| Report Abuse |
|
|
|
| 29 Jun 2014 12:21 AM |
| You localized the declaration statements there, so they are unusable outside the if statement. Either declare the value before entering the IF block, or don't declared it as local. |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 29 Jun 2014 12:22 AM |
It's for my gui it needs to find if map 1 2 or 3 is in workspace so it can search map 1 2 or 3 for spawns 1 2 3 4
heres another one I tried
function FindSpawns ()
local spawns Map1 = Workspace:FindFirstChild("Map1") Map2 = Workspace:FindFirstChild("Map2") Map3 = Workspace:FindFirstChild("Map3") spawns = {Map1,Map2,Map3} for c,v in pairs(MapTable) do SelectedMap = v:GetChildren() end end |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 29 Jun 2014 12:24 AM |
| I would like to mention I have maybe a 2 weeks of scripting experience or so I just learned and I've been forcing myself to learn as fast as possible because I want to make a cool game my friends and I would like. |
|
|
| Report Abuse |
|
|
|
| 29 Jun 2014 12:31 AM |
Try this:
function onClicked() local iterator = 0; local map = nil; local player = game.Players.LocalPlayer; -- Only works in a LocalScript. repeat i=i+1; map=game.Workspace:findFirstChild("Map"..i); until map or i>3; if (i<=3) then local spawn = map:findFirstChild("Spawn"..math.random(1,4)); player.Character:MoveTo(spawn.Position); else print("No map found!"); end; end
That should select the map if found, then teleport to either Spawn1, Spawn2, Spawn3, or Spawn4. |
|
|
| Report Abuse |
|
|
|
| 29 Jun 2014 12:31 AM |
| Wait, replace my 'local iterator = 0' with 'local i = 0'. Caught that. |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 29 Jun 2014 12:33 AM |
01:32:57.088 - attempt to call a nil value 01:32:57.090 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 29 Jun 2014 12:33 AM |
oops 01:32:55.518 - Attempt to connect failed: Passed value is not a function 01:32:55.519 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.SpawnScript', Line 19 01:32:55.520 - Stack End 01:32:55.521 - Attempt to connect failed: Passed value is not a function 01:32:55.521 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.SpawnScript', Line 20 01:32:55.522 - Stack End 01:32:55.523 - Attempt to connect failed: Passed value is not a function 01:32:55.524 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.SpawnScript', Line 21 01:32:55.525 - Stack End 01:32:55.526 - Attempt to connect failed: Passed value is not a function 01:32:55.527 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.SpawnScript', Line 22 01:32:55.528 - Stack End 01:32:55.529 - Attempt to connect failed: Passed value is not a function 01:32:55.530 - Script 'Players.Player1.PlayerGui.Weapon Choose GUI.SpawnScript', Line 23 01:32:55.531 - Stack End 01:32:57.088 - attempt to call a nil value 01:32:57.090 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 29 Jun 2014 12:44 AM |
function onClicked() local iterator = 0; local map = nil; local player = game.Players.LocalPlayer; -- Only works in a LocalScript. repeat i=i+1; map=game.Workspace:findFirstChild("Map"..i); until map or i>3; if (i<=3) then local spawn = map:findFirstChild("Spawn"..math.random(1,4)); player.Character:MoveTo(spawn.Position); else print("No map found!"); end; end
script.Parent.Main.Assault.MouseButton1Up:connect(OnClicked) script.Parent.Main.Commando.MouseButton1Up:connect(OnClicked) script.Parent.Main.Sniper.MouseButton1Up:connect(OnClicked) script.Parent.Main.Scout.MouseButton1Up:connect(OnClicked) script.Parent.Main.Demolition.MouseButton1Up:connect(OnClicked) |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
| |
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
| |
|
KEVEKEV77
|
  |
| Joined: 12 Mar 2009 |
| Total Posts: 6961 |
|
|
| 29 Jun 2014 11:25 PM |
Change iterator variable to i
name it i instead of iterator |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
| |
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
| |
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 30 Jun 2014 09:05 PM |
the first guy was right at first, but then went way cold
add quotation marks to map1 map2 map3 and map4 |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 30 Jun 2014 09:33 PM |
| Could you specify by taking the script line, and there is no map 4 at the moment. |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
| |
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
| |
|
lolb3
|
  |
| Joined: 16 Jan 2010 |
| Total Posts: 2268 |
|
|
| 01 Jul 2014 10:41 PM |
| PUT QUOTES AROUND THE MAP1 MAP2 MAP3 S INSIDE THE FIND FIRST CHILD FUNCTION this is like the 5th time its been said |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 01 Jul 2014 11:22 PM |
| 1 its the second time, 2 if you bothered to learn how to read instead of being a 1600th century pleb I stated which line which means I'm specifying which script would I need the quotes around it because one of my scripts I have quotes. |
|
|
| Report Abuse |
|
|
tarrdo
|
  |
| Joined: 24 Jun 2008 |
| Total Posts: 476 |
|
|
| 02 Jul 2014 02:52 PM |
Well I tried all the scripts on this and none of them changed anything so I tried something and it didn't work, so heres what I have it as.
function OnClicked() i = {"Map1","Map2","Map3"} spawns = {"1","2","3","4"} spawn = spawns[math.random(1,#spawns)] i = Workspace.Map:findFirstChild(spawn) game.Players.LocalPlayer.Character.Torso.CFrame = Workspace[math.random(4)].CFrame end script.Parent.Main.Assault.MouseButton1Up:connect(OnClicked) script.Parent.Main.Commando.MouseButton1Up:connect(OnClicked) script.Parent.Main.Sniper.MouseButton1Up:connect(OnClicked) script.Parent.Main.Scout.MouseButton1Up:connect(OnClicked) script.Parent.Main.Demolition.MouseButton1Up:connect(OnClicked)
Can anyone help me? |
|
|
| Report Abuse |
|
|