IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:10 PM |
Trying to make a map changer using InsertService, Any help?
while true do ids = {84350087,78235041} local map = math.random(1, #ids) game:GetService("InsertService"):Insert(map) map:MoveTo(Vector3.new(-81, 40.7, 20)) wait(10) -- I will change the time, this is just a test map:destroy() end
|
|
|
| Report Abuse |
|
|
|
| 31 May 2013 05:15 PM |
| Wow, you are all better scripters then me o.e |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:17 PM |
I'm not even sure if that is a correct function, I'm still learning myself haha!
Anyways, for those helping, this is the output!
23:16:05.189 - Unable to cast value to Object 23:16:05.189 - Script "Workspace.MapScript", Line 4 23:16:05.189 - stack end |
|
|
| Report Abuse |
|
|
| |
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:21 PM |
No, here's a tip, there's usually a "-" next to some words in blue, however many dashes there are within the lines your writing of that function, that is how many ends there must be
e.g. - function ontesting() - if bla bla bla then stuff here
end end
--- Notice how I've put two ends because there is two dashes. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:22 PM |
I've edited the script, and this is the output now:
23:22:10.584 - Workspace.MapScript:6: attempt to index local 'map' (a number value) 23:22:10.594 - Script "Workspace.MapScript", Line 6 23:22:10.594 - stack end
Here is the script code: while true do ids = {84350087,78235041}
local map = math.random(1, #ids) game:GetService("InsertService"):LoadAsset(map) map.Parent = game.Workspace map:MoveTo(Vector3.new(-81, 40.7, 20)) wait(10) -- position here map:destroy() end
|
|
|
| Report Abuse |
|
|
|
| 31 May 2013 05:23 PM |
| My first script had a function later in... and it didn't have a '-' at the start..? |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 31 May 2013 05:24 PM |
I don't exactly know if this is your issue, but I believe it should be changed. It should cause issues when it comes to using the variable. local map = math.random(1, #ids) Using :Insert() wouldn't work how you would want it to.
So..
while true do ids = {84350087,78235041} local mp = math.random(1, #ids) map = game:GetService("InsertService"):LoadAsset(ids[mp]) map.Parent = Workspace map:MoveTo(Vector3.new(-81, 40.7, 20)) wait(10) -- I will change the time, this is just a test map:destroy() end
I believe that should be correct, or at least closer to being correct. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:24 PM |
No the little "-" is within the margin, next to the number lines It's like this:
1 - function blabla() 2 3 |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:25 PM |
| Yeah, Insert() wouldn't work, LoadAsset is better, I'll test this! Thanks. |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:26 PM |
| Excellent, works! Thanks for your help. |
|
|
| Report Abuse |
|
|
grimm343
|
  |
| Joined: 18 Sep 2008 |
| Total Posts: 2796 |
|
|
| 31 May 2013 05:27 PM |
| No problem. Best of luck with your game! |
|
|
| Report Abuse |
|
|
IceOrb
|
  |
| Joined: 02 May 2010 |
| Total Posts: 1206 |
|
|
| 31 May 2013 05:29 PM |
| Thank you! Guess you've heard of it then, haha has become a popular post within game design. |
|
|
| Report Abuse |
|
|