So, I made a map loading script, and the problem is that the script, is ment to pick one of the 5 maps randomly, it works, the porblem is that it does it too many times, it's only ment to do it once. Well, I know what to do to fix it, I just don't know how... I mean I know I have to use it as a function, not a while wait.. And I know that theres a way to do the function whenever a value changes... I just don't know how! Help?
RoundStart = game.Workspace.RoundStart
Room1 = game.ServerStorage.Room1
Room2 = game.ServerStorage.Room2
Room3 = game.ServerStorage.Room3
Room4 = game.ServerStorage.Room4
Room5 = game.ServerStorage.Room5
while wait() do
wait(1)
if RoundStart.Value == true then
RandomRoom = (math.random(5))
if RandomRoom == 1 then
Map1 = Room1:Clone()
Map1.Parent = game.Workspace
end
if RandomRoom == 2 then
Map1 = Room2:Clone()
Map1.Parent = game.Workspace
end
if RandomRoom == 3 then
Map1 = Room3:Clone()
Map1.Parent = game.Workspace
end
if RandomRoom == 4 then
Map1 = Room4:Clone()
Map1.Parent = game.Workspace
end
if RandomRoom == 5 then
Map1 = Room5:Clone()
Map1.Parent = game.Workspace
end
end
end

3 comments
Um what? If you only want it to happen once then don't put it in a loop. Or if you want put it in a function so you can call it multiple times.
Yeah, I know the point is, I want to put it in a function, I just don't know what... Event?.. To use to use that function when the bool value "RoundStart" Changes..
I think you SHOULD make all of your Map1 =... be a local Map1