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 » Scripters
Home Search
 

Re: Destroy is a nil value, idk how to fix

Previous Thread :: Next Thread 
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 01:41 PM
Map = game.ServerStorage.HoloMaps
maps = {"Holo", "MapEasyJumps", "MapMeadowsBridges"}

function cc()
for _,v in pairs(maps) do
if v then
v:Destroy()
end
end
end

--OBBIES
script.Parent.FrameObbyMaps.FrameObbyJumps.BtnEasyJumps.MouseButton1Down:connect(function()
cc()
local map = Map.ObbyMaps.MapEasyJumps:Clone()
Map.Parent = workspace
table.insert(maps,map)
end


CZ
Report Abuse
IcedVapour is not online. IcedVapour
Joined: 10 Nov 2013
Total Posts: 2741
10 Mar 2017 01:43 PM
maps

change this to Maps
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
10 Mar 2017 01:44 PM
cc = function()
for _,map in pairs(maps:GetChildren()) do
if v then v:Destroy() end
end
end
Report Abuse
IcedVapour is not online. IcedVapour
Joined: 10 Nov 2013
Total Posts: 2741
10 Mar 2017 01:45 PM
maps is a table with strings

you cant destroy strings
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 01:46 PM
@Gom

GetChildren() is now a Nil value


CZ
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 01:47 PM
@Iced

How would I do it differently?


CZ
Report Abuse
IcedVapour is not online. IcedVapour
Joined: 10 Nov 2013
Total Posts: 2741
10 Mar 2017 01:48 PM
what are you trying to do?
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
10 Mar 2017 01:48 PM
heres a better way to insert something into a table.

local namehere = {"...", "ugh"}
local something

if something ~= then namehere[#namehere+1] = something end

spawn(function()
while wait(10) do
print(#namehere)
end
end
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
10 Mar 2017 01:49 PM
map* instead of "v"
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
10 Mar 2017 01:51 PM
I wrote this code for you. maps is supposed to be initially empty. It it meant to hold the actual map models that are in the workspace. That's why cc() calls Destroy() on the items in the array.
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
10 Mar 2017 01:52 PM
In fact, I don't even know why i used an array in the first place, if only one map will be used at a time.

Map = game.ServerStorage.HoloMaps
CurrentMap = nil

function cc()
if CurrentMap then
CurrentMap:Destroy()
end
end

--OBBIES
script.Parent.FrameObbyMaps.FrameObbyJumps.BtnEasyJumps.MouseButton1Down:connect(function()
cc()
local map = Map.ObbyMaps.MapEasyJumps:Clone()
Map.Parent = workspace
CurrentMap = map
end
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 01:54 PM
@Mister

Sorry for not giving credit at first, When I click a button, it spawns every map in "HoloMaps"

It takes the Model "HoloMaps" from ServerStorage and pastes in Workspace.


CZ
Report Abuse
IcedVapour is not online. IcedVapour
Joined: 10 Nov 2013
Total Posts: 2741
10 Mar 2017 01:56 PM
you cannot use MouseButton1Down in normal scripts
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
10 Mar 2017 01:57 PM
To fix that you just need to reference the correct model inside of HoloMaps when you make the copy.
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 01:58 PM
@Mister

The new script worked ish, when I click a different map, it doesn't delete the previous map.


CZ
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 01:59 PM
@Iced

Would I be able to use MouseButton1Click?


CZ
Report Abuse
IcedVapour is not online. IcedVapour
Joined: 10 Nov 2013
Total Posts: 2741
10 Mar 2017 02:01 PM
no

you need to put it in a localscript inside starterplayerscripts
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
10 Mar 2017 02:05 PM
Now that it's in a local script you'll need to call a remote event to access the maps from server storage.
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 02:05 PM
If I put it in local scripts, wouldn't it just spawn the map only for me and not anyone else in the game?


CZ
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 02:06 PM
@mister

I'm sorry I don't know what that is lol, I only know the basic stuff.


CZ
Report Abuse
Mister_Manakin is not online. Mister_Manakin
Joined: 16 Sep 2009
Total Posts: 1935
10 Mar 2017 02:06 PM
Use a remote event so that the map spawns on the server side.
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 02:07 PM
How do I use a Remote event? I don't know what that is.


CZ
Report Abuse
Oryxide is not online. Oryxide
Joined: 09 Jul 2015
Total Posts: 647
10 Mar 2017 02:35 PM
To my knowledge. A RemoteEvent can call a RemoteFunction. So though the script is in a local script, if you do the right coding it'll make the Map spawn for everyone else aswell.
Report Abuse
ChadZer is online. ChadZer
Joined: 14 Dec 2010
Total Posts: 653
10 Mar 2017 02:38 PM
Oh, I don't know how to do that.


CZ
Report Abuse
Oryxide is not online. Oryxide
Joined: 09 Jul 2015
Total Posts: 647
10 Mar 2017 02:41 PM
Learn to code like me.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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