generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Help asap please,

Previous Thread :: Next Thread 
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
27 Oct 2014 03:52 AM
I just keep getting this error "19:50:38.559 - Workspace.GameManager:793: attempt to index global 'a' (a nil value)"


function _G.changeMap(map)
print(map.Name .. " is being loaded.")
local totalSpace = 0
local list = game.Workspace.Map:getChildren()
for x=1, #list do
list[x]:remove()
end
a = game.Lighting.Maps[map]:Clone()
a.Parent = game.Workspace
a.Name = "Map"
end
for _, v in pairs (a:GetChildren()) do
if a.className == "Part" and a.TopSurface == "Studs" then
totalSpace = totalSpace + 1
end
local nameData = _G.explode("|", a.Data.Value)

if _G.skyBox then
_G.changeSky(nameData[2])
end


script.maxUsage.Value = totalSpace * (percentAvailable / 100)
script.mapName.Value = a.Name
return _G.decompressed
end
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
27 Oct 2014 04:38 AM
bump
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
27 Oct 2014 04:42 AM
game.Lighting.Maps[map]:Clone() either returns nil or you need to set it to local
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 08:11 AM
Please help fix it guys.
Report Abuse
iondriver is not online. iondriver
Joined: 18 Nov 2012
Total Posts: 757
28 Oct 2014 08:22 AM
Unless you have already defined a, then you need to put local by it. I.E,

local a = game.Lighting.Maps[map]:Clone()
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 08:25 AM
Changed it and the map spawned, but it still didnt do the for_,v in pairs
partt


function _G.changeMap(map)
print(map.Name .. " is being loaded.")
local totalSpace = 0
local list = game.Workspace.Map:getChildren()
for x=1, #list do
list[x]:remove()

end
local a = map:Clone()
a.Parent = game.Workspace
a.Name = "Map"
for _, v in pairs (a:GetChildren()) do
if a.className == "Part" and a.TopSurface == "Studs" then
totalSpace = totalSpace + 1
end
end
local nameData = _G.explode("|", a.Data.Value)

if _G.skyBox then
_G.changeSky(nameData[2])
end


script.maxUsage.Value = totalSpace * (percentAvailable / 100)
script.mapName.Value = a.Name
return _G.decompressed
end
Report Abuse
iondriver is not online. iondriver
Joined: 18 Nov 2012
Total Posts: 757
28 Oct 2014 08:30 AM
change a.className to a:IsA("Part"). This is usually preferred. Does the console give you any errors?
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 08:33 AM
No errors, it's just not increasing the value.

Report Abuse
iondriver is not online. iondriver
Joined: 18 Nov 2012
Total Posts: 757
28 Oct 2014 08:39 AM
--goes after a--
local ac = a:GetChildren()

for i=1, #ac do
if ac[i]:IsA("Part") and ac[i].TopSurface == "Studs" then
totalSpace = totalSpace + 1
end
end

Should work. I have not tested it though.
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 08:43 AM
nope :(
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 09:00 AM
current script, only problem is totalspace isn't changing



function _G.changeMap(map)
print(map.Name .. " is being loaded.")
local totalSpace = 0
local list = game.Workspace.Map:getChildren()
for x=1, #list do
list[x]:remove()
end
local a = map:Clone()
a.Parent = game.Workspace
a.Name = "Map"
local ac = a:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac[i].TopSurface == "Studs" then
totalSpace = totalSpace + 1
end
end
--local nameData = _G.explode("|", a.Data.Value)

--if _G.skyBox then
--_G.changeSky(nameData[2])
--end


script.maxUsage.Value = totalSpace * (10 / 100)
script.mapName.Value = map.Name
return _G.decompressed
end

Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
28 Oct 2014 09:03 AM
ac[i].TopSurface == "Studs"
This doesn't work, as far as I know, that only works to set it.

use

ac[i].TopSurface == Enum.SurfaceType.Studs
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 09:05 AM
You legend!

it's working, thank you everyone!
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 11:23 AM
I've changed one part, after it's spawned I want it to, remove every model called Forest and replace it with one called Forest from lighting, and the same thing but with Gold. No output, please help.


function _G.changeMap(map)
print(map.Name .. " is being loaded.")
local totalSpace = 0
local list = game.Workspace.Map:getChildren()
for x=1, #list do
list[x]:remove()
end
local a = map:Clone()
a.Parent = game.Workspace
a:MoveTo (Vector3.new(191.6, 8, 360))
a.Name = "Map"

local ac = a:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac[i].TopSurface == Enum.SurfaceType.Studs then
totalSpace = totalSpace + 1
end
end
local ac = game.Workspace.Map:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac.Forest ~= nil then
ac.Forest:Destroy()
local res = game.Lighting.Database.NaturalResources.Forest:clone()
res.Parent = ac
res:MoveTo(ac.Position + Vector3.new(3, 0, 3))
end
end
local ac = game.Workspace.Map:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac.Gold ~= nil then
ac.Gold:Destroy()
local res = game.Lighting.Database.Gold:clone()
res.Parent = ac
res:MoveTo(ac.Position)
end
end



local nameData = _G.explode("|", a.Data.Value)

if _G.skyBox then
_G.changeSky(nameData[2])
end


script.maxUsage.Value = totalSpace * (10 / 100)
script.mapName.Value = map.Name
return _G.decompressed
end



Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 11:36 AM
this is the part I need help with, please help.


local ac = game.Workspace.Map:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac.Forest ~= nil then
ac.Forest:Destroy()
local res = game.Lighting.Database.NaturalResources.Forest:clone()
res.Parent = ac
res:MoveTo(ac.Position + Vector3.new(3, 0, 3))
end
end
local ac = game.Workspace.Map:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac.Gold ~= nil then
ac.Gold:Destroy()
local res = game.Lighting.Database.Gold:clone()
res.Parent = ac
res:MoveTo(ac.Position)
end
end
Report Abuse
iondriver is not online. iondriver
Joined: 18 Nov 2012
Total Posts: 757
28 Oct 2014 11:44 AM
local ac = game.Workspace.Map:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac.Forest ~= nil then
ac.Forest:Destroy()
local res = game.Lighting.Database.NaturalResources.Forest:clone()--Replace lighting with serverStorage, and move everything into there. Usually better.
res.Parent = ac --< [[this is your problem. GetChildren() returns a read only table. try res.Parent = game.Workspace.Map]]--
res:MoveTo(ac.Position + Vector3.new(3, 0, 3))
end
end
local ac = game.Workspace.Map:GetChildren()
for i=1, #ac do
if ac[i]:IsA("Part") and ac.Gold ~= nil then
ac.Gold:Destroy()
local res = game.Lighting.Database.Gold:clone()
res.Parent = ac --< Do the same thing you did for forest here
res:MoveTo(ac.Position)
end
end

Report Abuse
iondriver is not online. iondriver
Joined: 18 Nov 2012
Total Posts: 757
28 Oct 2014 11:45 AM
If that doesn't work, change ac.Forest ~= nil to ac[I].Name == Forest. Same thing for gold.
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 11:52 AM
Gold and Forest are models in the parts
Report Abuse
DrunkAustralian is not online. DrunkAustralian
Joined: 02 Dec 2006
Total Posts: 3062
28 Oct 2014 11:56 AM
nevermind all I have got it working :D
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image