I have this piece of code and I have a folder in workspace, everytime I do something like game.workspace.workspacestoragefolder it says its not in the workspace but when I got look in workspace in play testing it there.
Try workspace:WaitForChild(āworkspacestoragefolderā)
It seemed not to work, it puts the maps into workspace and not the folder which was not intended at all as well the flags dont go to the folder inside of workspacestorage.
Whatās the folderās name, and where is it located ?
WorkspaceStorageFolder game > Workspace
FlagFolder game > workspace > WorkspaceStorageFolder > FlagFolder I can provide the script if you would like.
Could you show a little bit of the script so I can understand better ?
local MapChangerManager = {}
ā ROBLOX Services
local Players = game.Players
ā Local Variables
local Events = game.ReplicatedStorage.Events
local WorkspaceStorage = game.Workspace:WaitForChild(āWorkspaceStorageFolderā)
local Maps = game.ServerStorage.MapSave
ā Public Functions
function MapChangerManager:MakeNewMap()
local NewMap = math.random(1,4)
for _, child in ipairs(game.ServerStorage.GameModesFolder.CaptureTheFlag:GetChildren()) do
if child.Name == āFlagStandā then
child.Parent = WorkspaceStorage:WaitForChild(āFlagStandFolderā)
end
end
if NewMap == 1 then
local ClonedMap = Maps:FindFirstChild(āCastle Mapā):Clone()
ClonedMap.Parent = WorkspaceStorage:WaitForChild(āMapā)
elseif NewMap == 2 then
local ClonedMap = Maps:FindFirstChild(āForest Mapā):Clone()
ClonedMap.Parent = WorkspaceStorage:WaitForChild(āMapā)
elseif NewMap == 3 then
local ClonedMap = Maps:FindFirstChild(āCastle Mapā):Clone()
ClonedMap.Parent = WorkspaceStorage:WaitForChild(āMapā)
elseif NewMap == 4 then
local ClonedMap = Maps:FindFirstChild(āForest Mapā):Clone()
ClonedMap.Parent = WorkspaceStorage:WaitForChild(āMapā)
end
endfunction MapChangerManager:DeleteMap()
WorkspaceStorage.Map:ClearAllChildren()
for _, child in ipairs( WorkspaceStorage.FlagStandFolder:GetChildren()) do
if child.Name == āFlagStandā then
child.Parent = game.ServerStorage.GameModesFolder.CaptureTheFlag
end
end
endreturn MapChangerManager
The maps seems to be cloning into the map folder correctly, I donāt see any problem with the cloning.
Yeah it clones but it goes to the workspace let me send a screenshot but it doesnt go to the folder let me send the errors wait 1 second
Wait I fixed it! It was an error with the main script as well what you said earlier!
Alr nice to hear, glad to be of help.
I appreciate the help! Must get going now!
Not sure how to fix your error, but I wanted to point out a useful simplification you can do.
Instead of doing:
you can do:
local MapNames = {"Castle","Forest","Castle","Forest"}
local ClonedMap = Maps:FindFirstChild(tostring(MapNames[NewMap]))
if ClonedMap then
ClonedMap = ClonedMap:Clone()
ClonedMap.Parent = WorkspaceStorage:WaitForChild("Map")
end
Thank you! I have been wondering how to do something like that cause my scripts get lengthy as well it mostly picks the number 1. I really appreciate it you have made my life easier!
Is it normal for it to have a red underline under it?
Where at? (and no, red underlines usually mean errors and the script could break)
function MapChangerManager:MakeNewMap()
for _, child in ipairs(game.ServerStorage.GameModesFolder.CaptureTheFlag:GetChildren()) do
if child.Name == āFlagStandā then
child.Parent = WorkspaceStorage:WaitForChild(āFlagStandFolderā)
end
end
local ClonedMap = Maps:FindFirstChild(tostring(MapNames[NewMap]))
if ClonedMap then
ClonedMap = ClonedMap:Clone()
ClonedMap.Parent = WorkspaceStorage:WaitForChild(āMapā)
end
end
its at the part that says NewMap it says unknown global āNewmapā
Itās because you forgot to add the random part:
local NewMap = math.random(1,4)
and the table of names I provided.
ohhhhhhhhhhhhh I deleted it out the script
so if theres 2 maps do i change the random value to 1,2?