Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to find a model, then change his parent?

Asked by 5 years ago

So I'm trying to make a basic map cache that after it is selected, it would take the last map from the cache and put it back in the pool and then take the selected map and put it in the cache. However, my method doesn't take the last map from the cache, so the game works until it runs out of maps. Here's the script:

local currentMap = MapsToChoose[math.random(#MapsToChoose)]
local workspace_map = game.ServerStorage.Maps[currentMap]:Clone()
local outside_map = game.ServerStorage.Maps[currentMap]
local outcache = game.ServerStorage.OutMaps
workspace_map.Parent = game.Workspace.CurrentMap
outcache:GetChildren().Parent = game.ServerStorage.Maps
outside_map.Parent = game.ServerStorage.OutMaps
0
:GetChilden() returns a table value, you need to make for i,v in pairs(outcache:GetChildren()) do loop and change all of the object's parent, unless you only have one map in the outcache marijus06 68 — 5y
8
Do not assume a model's gender. DeceptiveCaster 3761 — 5y
0
lmao good one, deserves an upvote Gameplayer365247v2 1055 — 5y

1 answer

Log in to vote
0
Answered by
danglt 185
5 years ago
local currentMap = MapsToChoose[math.random(#MapsToChoose)]
local workspace_map = game.ServerStorage.Maps[currentMap]:Clone()
local outside_map = game.ServerStorage.Maps[currentMap]
local outcache = game.ServerStorage.OutMaps
workspace_map.Parent = game.Workspace.CurrentMap
for i,v do in  pairs(outcache:GetChildren()) do
v.Parent = game.ServerStorage.Maps
outside_map.Parent = game.ServerStorage.OutMaps
end
0
Nice syntax error on line 6. DeceptiveCaster 3761 — 5y
Ad

Answer this question