hey so i’m having an issue with a map selector script
what the script is supposed to do is generate a map once all buttons on the floor are pressed, everything works like the initial map pick and the random button placement but for some reason, the map doesn’t change when all the buttons are pressed
the number value changes when a button is pressed and this script basically checks when the number value is equal to the number of buttons in the buttons folder generated in workspace
i’ve been attempting to fix this for 3 days, and a lot of solutions others have provided don’t seem to work, unfortunately. i’ve tried editing how buttons spawn and the map generation stuff but it just gives the same result, no map changes, no new map loads, nothing.
should also mention that this gives me 0 errors in the output, so i don’t have a clue as to what’s causing this issue, it’s odd
here’s the code, if any further info about this is needed (that i know) i can provide
local chosenmap
function chooseSpawnPoints(spawnblocks) -- folder is the spawn parts folder we specified in the while loop
local tableA = spawnblocks:GetChildren()
local tableB = {} -- chosen blocks
local tabALength = #tableA
local maxspawnblocks = math.random(1,tabALength)
for i = 1,maxspawnblocks do
local randomNumber = math.random(1,tabALength) -- picks a random number of spawn blocks to replace with buttons
local chosen = tableA[randomNumber]
if chosen ~= nil then
table.insert(tableB,choosen) -- insert the choosen spawn block into table B
table.remove(tableA,randomNumber) -- removes the spawnBlocks table so it's not repeated
end
end
return tableB
end
local maps = game.ReplicatedStorage.maps:GetChildren() -- get a list of all the maps
local chosenMap = maps[math.random(1,#maps)]
chosenMap = chosenMap:Clone()
chosenMap.Parent = game.Workspace
local chosenblocks = chooseSpawnPoints(chosenMap.spawnblocks)
for i, block in pairs(chosenblocks) do
local button = game.ReplicatedStorage.button:Clone()
button:PivotTo(block.CFrame)
button.Parent = game.Workspace.Buttons
block:Destroy()
end
local buttonsPressed = game.Workspace.ButtonsPressed
local buttons = game.Workspace.Buttons:GetChildren()
buttonsPressed.Changed:Connect(function(property)
if property == "Value" then
if buttonsPressed.Value == #buttons then
wait(5)
chosenMap:Destroy()
buttons:Destroy()
wait(5)
chosenMap:Clone()
chosenMap.Parent = workspace
end
end
end)
any help is appreciated to help me fix this issue, thank you in advance