Hello, I am currently having trouble on inserting a value. Every time I do it, it gives me an error. If you know anything about this error or what it means and how I can possibly fix it, please let me know. Thanks! (And also, if you need any more information, I'd be glad to get you what you need.)
Error:
Workspace.GameScripts.Maps.FoggyRailroad:102: attempt to index upvalue 'table' (a nil value)
Workspace.GameScripts.Maps.FoggyRailroad scripts:
local table spikestween = { [1] = tweenspike1, [2] = tweenspike2, [3] = tweenspike3, [4] = tweenspike4, [5] = tweenspike5, [6] = tweenspike6, [7] = tweenspike7, [8] = tweenspike8, [9] = tweenspike9, [10] = tweenspike10, [11] = tweenspike11, [12] = tweenspike12, } local table avoidings = { [1] = "Train", [2] = "Zombies", [3] = "Spikes", [4] = "Brawl", [5] = "Bombs", [6] = "Lightning", [7] = "Tag", [8] = "Coin Multiplier", [9] = "Disco Players", [10] = "Gravity Coil", [11] = "Speed Coil", [12] = "Rocket Brawl", [13] = "Bomb Brawl", [14] = "Character Jam", [15] = "Murderer" } local table alreadyused = {} -- THIS IS THE TABLE USED local avoiding = nil game.ReplicatedStorage.CurrentMap.Changed:Connect(function() if rs.CurrentMap.Value == "Foggy Railroad" then rs.Foggy_Railroad.AvoidAdded:Fire("Trains") repeat avoiding = avoidings[5] if avoiding == "Zombies" then table.insert(alreadyused, "Zombies") for i = 5, 0, -1 do local clone = game.ServerStorage.Zombie:Clone() gfunction.teleportAnything(clone, game.Workspace.Railroad_Spawn) clone.Parent = workspace end else if avoiding == "Spikes" then table.insert(alreadyused, "Spikes") for i = 12, 1, -1 do spikestween[i]:Play() end else if avoiding == "Brawl" then table.insert(alreadyused, "Brawl") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.ClassicSword) end else if avoiding == "Bombs" then table.insert(alreadyused, "Bombs") -- THIS IS THE LINE THAT GOT THE ERROR rs.Foggy_Railroad.AvoidAdded:Fire("Bombs") else if avoiding == "Lightning" then table.insert(alreadyused, "Lightning") rs.Foggy_Railroad.AvoidAdded:Fire("Lightning") else if avoiding == "Tag" then table.insert(alreadyused, "Tag") -- Do Later else if avoiding == "Coin Multiplier" then table.insert(alreadyused, "Coin Multiplier") else if avoiding == "Disco Players" then table.insert(alreadyused, "Disco Players") rs.Foggy_Railroad.AvoidAdded:Fire("Disco Players") else if avoiding == "Gravity Coil" then table.insert(alreadyused, "Gravity Coil") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.GravityCoil) end else if avoiding == "Speed Coil" then table.insert(alreadyused, "Speed Coil") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.SpeedCoil) end else if avoiding == "Rocket Brawl" then table.insert(alreadyused, "Rocket Brawl") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.RocketLauncher) end else if avoiding == "Bomb Brawl" then table.insert(alreadyused, "Bomb Brawl") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.Bomb) end else if avoiding == "Character Jam" then table.insert(alreadyused, "Character Jam") rs.Foggy_Railroad.AvoidAdded:Fire("Character Jam") else if avoiding == "Murderer" then local randomplayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())] gfunction.giveGear(randomplayer, game.ServerStorage.Handgun) end end end end end end end end end end end end end end wait(15) until game.ReplicatedStorage.CurrentMap ~= "Foggy Railroad" end end)
local spikestween = {"tweenspike1", "tweenspike2", "tweenspike3", "tweenspike4", "tweenspike5", "tweenspike6", "tweenspike7", "tweenspike8", "tweenspike9", "tweenspike10", "tweenspike11", "tweenspike12"} local avoidings = {"Train", "Zombies", "Spikes", "Brawl", "Bombs", "Lightning", "Tag", "Coin Multiplier", "Disco Players", "Gravity Coil", "Speed Coil", "Rocket Brawl", "Bomb Brawl", "Character Jam", "Murderer"} local alreadyused = {} -- THIS IS THE TABLE USED local avoiding = nil game.ReplicatedStorage.CurrentMap.Changed:Connect(function() if rs.CurrentMap.Value == "Foggy Railroad" then rs.Foggy_Railroad.AvoidAdded:Fire("Trains") repeat avoiding = avoidings[5] if avoiding == "Zombies" then table.insert(alreadyused, "Zombies") for i = 5, 0, -1 do local clone = game.ServerStorage.Zombie:Clone() gfunction.teleportAnything(clone, game.Workspace.Railroad_Spawn) clone.Parent = workspace end else if avoiding == "Spikes" then table.insert(alreadyused, "Spikes") for i = 12, 1, -1 do spikestween[i]:Play() end else if avoiding == "Brawl" then table.insert(alreadyused, "Brawl") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.ClassicSword) end else if avoiding == "Bombs" then table.insert(alreadyused, "Bombs") -- THIS IS THE LINE THAT GOT THE ERROR rs.Foggy_Railroad.AvoidAdded:Fire("Bombs") else if avoiding == "Lightning" then table.insert(alreadyused, "Lightning") rs.Foggy_Railroad.AvoidAdded:Fire("Lightning") else if avoiding == "Tag" then table.insert(alreadyused, "Tag") -- Do Later else if avoiding == "Coin Multiplier" then table.insert(alreadyused, "Coin Multiplier") else if avoiding == "Disco Players" then table.insert(alreadyused, "Disco Players") rs.Foggy_Railroad.AvoidAdded:Fire("Disco Players") else if avoiding == "Gravity Coil" then table.insert(alreadyused, "Gravity Coil") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.GravityCoil) end else if avoiding == "Speed Coil" then table.insert(alreadyused, "Speed Coil") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.SpeedCoil) end else if avoiding == "Rocket Brawl" then table.insert(alreadyused, "Rocket Brawl") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.RocketLauncher) end else if avoiding == "Bomb Brawl" then table.insert(alreadyused, "Bomb Brawl") for i,p in ipairs(game.Players:GetPlayers()) do gfunction.giveGear(p, game.ServerStorage.Bomb) end else if avoiding == "Character Jam" then table.insert(alreadyused, "Character Jam") rs.Foggy_Railroad.AvoidAdded:Fire("Character Jam") else if avoiding == "Murderer" then local randomplayer = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())] gfunction.giveGear(randomplayer, game.ServerStorage.Handgun) end end end end end end end end end end end end end end wait(15) until game.ReplicatedStorage.CurrentMap ~= "Foggy Railroad" end end)
Try it now. The way you written your tables was incorrect. It should be written the way I did them. In addition, you do not need to define that you're using a table by doing this:
local table a = {} --THIS IS WRONG!
This is correct:
local a = {}
The { }
lets it know you're making a table.
Also, I do not know if this is part of a larger script but make sure that rs
and gfunction
is correctly defined within the script.