#Map Randomizer

32 messages · Page 1 of 1 (latest)

zenith isle
#

Trying to make it so that whenever “InRound” is true (when the round is happening) it picks a random map and brings it to the workspace and when it’s false the map goes back to replicated storage. For some reason when InRound is true, no map is brought to the workspace

digital charmBOT
#

studio** You are now Level 1! **studio

clear garden
#

just clone it

#

and destroy the clone when you finish with it

#

less overhead

#

annd your code is quite overcomplicated, the if statements might be the thing messing with it

#

but you can just do

#
local MapsArray = rep.Maps:GetChildren()

local ChosenMap = nil

InRound.Changed:Connect(function(inRound)
  if inRound then
    ChosenMap = MapsArray[math.random(1, #MapsArray)]:Clone() 
    ChosenMap.Parent = workspace
  
  else not inRound and ChosenMap ~= nil then
      ChosenMap:Destroy()
  end
end)
#

that's about it

#

no need to overcomplicate mate

zenith isle
zenith isle
#

“Attempt to index boolean with ‘changed’”

frank stump
zenith isle
#

A bool value

#

So that’s the problem

#

I just don’t know how else to do it i cant use .changed with a bool value

clear garden
clear garden
#

it's Changed

#

capital c

zenith isle
#

Yeah ik i didnt completely copy paste it

#

Ok got it to work apparently you don’t have to add .value when referencing the bool value no idea why but it works thanks!

clear garden
# zenith isle Ok got it to work apparently you don’t have to add .value when referencing the b...

Follow me on:
Twitter: https://twitter.com/iced_coffee_dev
Github: https://github.com/simondevyoutube/

This video covers pass by value vs pass by reference in JavaScript, an important and fundamental concept in computer science. We'll be doing a deep dive, covering how memory allocation of variables works, how function argument passing is done,...

▶ Play video
#

this applies to all programming languages btw

#

not just roblox

#

you are basically a value not the object value value 🙂

nimble haven
#

complicated script

#

local Chosen = math.random(1, 4)
local Maps = {
  [1] = {
    ["Map"] = ReplicatedStorage["Map #1"]
  }
}

for v, _ in ipairs(Maps) do
  if v == Chosen then
    v["Map"]:Clone().Parent = workspace
  end
end