|
| 30 Mar 2013 08:20 AM |
So here's the script:
specialPlayersOnly = true
showMessages = true
maps = {"AirP", "SIMRemove", "BasicSF"}
playerList = {"secret56310", "JasonIIII", "BrainK2355", "SONICTHEHEDGEHOGXX", "EliteHunter699", "xWOWZABOYx", "Dracorex001", "Crystalality", "Byas", "PerilousDanger", "SonicGuy25", "antony68204", "laxman15", "Rebelliousdude", "RAG3GUY", "Ffernando"}
command = "LOAD "
function printMessage(text) if showMessages == true then msg = Instance.new("Message", game.Workspace) msg.Text = text wait(3) msg:Remove() else end end
function removeCurrentMap(newMap) for i = 1, #maps do if maps[i] ~= newMap then if game.Workspace:findFirstChild(maps[i]) then game.Workspace:findFirstChild(maps[i]):Remove() printMessage(game.Workspace:findFirstChild(maps[i]).Name.." Removed") end end end end
function setNewMap(newMap) if game.Lighting:findFirstChild(newMap) then game.Lighting:findFirstChild(newMap):Clone().Parent = game.Workspace printMessage(newMap.." Loaded") else printMessage(newMap.." NotFound") end end
function checkMessage(msg) for i = 1, #maps do if msg == command..maps[i] then removeCurrentMap(maps[i]) wait(1) setNewMap(maps[i]) end end end
game.Players.PlayerAdded:connect(function(player) if specialPlayersOnly then for i = 1, #playerList do if player.Name == playerList[i] then player.Chatted:connect(checkMessage) end end else player.Chatted:connect(checkMessage) end end)
Anyways, the script throws an error: Workspace.LoadMapOnChat:25: attempt to index a nil value
Here's the stack trace: Workspace.LoadMapOnChat, line 25 - global removeCurrentMapWorkspace.LoadMapOnChat, line 43
Let's say I load the first map, then try and load the second.
It'll load map#1 and say "map#1 Loaded" in a message. Then when I try and load the second one, it removes map#1, but then throws an error, and doesn't come up with a message or load map#2.
I'm not entirely sure what I've done wrong, help, please?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 10:40 AM |
| Uhm, you said "map[i].Name" and then tried to remove it. Your "maps" are strings, not objects, so you cannot "index" them. (Index is ... what you do to tables and objects, but a dot to access another thing thats inside it, in this case, Name) |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 11:53 AM |
So if I changed it to this:
printMessage(game.Workspace:findFirstChild(maps[i]).." Removed")
it'd work?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 12:00 PM |
Nope, still throws an error. This time, trying to concentrate a nil value.
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
12packkid
|
  |
| Joined: 24 Jun 2011 |
| Total Posts: 1418 |
|
|
| 30 Mar 2013 12:03 PM |
Concentrating a nil value means, you're trying to edit something that does not exist. And then trying to do more stuff with it.
†† 12packkid ∞∞ LuaLearners Teacher ≠≠ Wind is light, but darker... †† |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 12:54 PM |
Well can someone tell me how to fix the script then please?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|