|
| 30 Mar 2013 09:28 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 01:07 PM |
Someone?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
love07818
|
  |
| Joined: 10 Sep 2012 |
| Total Posts: 17 |
|
|
| 30 Mar 2013 01:47 PM |
| I don't know. Im not good at scripting. Soz. |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 01:53 PM |
...then why post?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 02:24 PM |
Anyone?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
Vhozon
|
  |
| Joined: 31 Jan 2012 |
| Total Posts: 250 |
|
|
| 30 Mar 2013 02:29 PM |
game.Workspace:findFirstChild(maps[i]):Remove() -- First remove it... printMessage(game.Workspace:findFirstChild(maps[i]).Name.." Removed") -- Then try to access its name? |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 30 Mar 2013 02:31 PM |
:Remove() sets the parent to nil, but it can still be modified.
If he used :Destroy(), then he wouldn't be able to do that. |
|
|
| Report Abuse |
|
|
Vhozon
|
  |
| Joined: 31 Jan 2012 |
| Total Posts: 250 |
|
|
| 30 Mar 2013 02:43 PM |
printMessage(game.WORKSPACE:FINDFIRSTCHILD(maps[i]).Name.." Removed")
As its parent is NIL, it is not WORKSPACE, so FINDFIRSTCHILD cannot find it. |
|
|
| Report Abuse |
|
|
Xnite515
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 22763 |
|
|
| 30 Mar 2013 02:46 PM |
thank you for showing us line 25.
/sarcasm |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 30 Mar 2013 02:46 PM |
eh.
It's called being too lazy to read. |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 02:47 PM |
Mk, so swotch those to lines over?
(I also changed it to :Destroy() because I prefer it)
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
Vhozon
|
  |
| Joined: 31 Jan 2012 |
| Total Posts: 250 |
|
| |
|
Vhozon
|
  |
| Joined: 31 Jan 2012 |
| Total Posts: 250 |
|
|
| 30 Mar 2013 02:48 PM |
| You are not the original author of this script, neither a scripter or a person, who wants to learn scripting as it seems. I will not continue to help you. |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 02:56 PM |
A: Never said I was B: Actually, I am C: I am learning FROM this script. I knew it was broken, and tried to fix it as far as I could. Then I got stuck and asked for this thing called help.
It now works perfectly, thank you very much.
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
Vhozon
|
  |
| Joined: 31 Jan 2012 |
| Total Posts: 250 |
|
|
| 30 Mar 2013 03:00 PM |
If you had written this script, you would have a brain. If you had a brain, you would be able the exchange two lines. |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 05:47 PM |
I didn't notice them.
That's why I asked for help, because I didn't notice them. Why are you being so offensive all of a sudden? What the hell did I do to you?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCO, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|