Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Clone random map from serverstorage still isn't working??

Ok, so again this isn't working...the output says Map# isn't a valid member of serverstorage, even though it is.

maparea = math.random(1,3)
min = 0
sec = 5

print("start1")
print(maparea)
repeat 
	script.Parent.Text = (min..":"..sec)
			sec = sec - 1
            wait(1)
            if sec == 0 then
				wait(0.1)
                min = min - 1
                sec = 59
print("minus 1 minute")
end
until min == -1
wait(0.1)
min = 0
sec = 0
script.Parent.Text = (min..":"..sec)
wait(5)
game.ServerStorage("Map" ..maparea).Name:Clone().Parent = game.Workspace



while true do
	wait()
	game.Players.LocalPlayer.PlayerGui.Timer.Clock.TimeLeft.Text = (min..":"..sec)
end

Line 23 is where it says that it isn't a member of serverstorage. Everything except that works fine.

1 answer

✓ Accepted answer

Change line 23 to:

game.ServerStorage["Map"..maparea]:Clone().Parent = workspace

Remember that parentheses go next to a function. Use brackets when you are trying to index a table with a non literal string. There is a difference between x(5) and x[5]. The first one means that you are calling a function called x with an argument of five, while the latter means that you are indexing the table x with five.

In addition, the script above is local but the Server Storage is only accessible by the server hence the name. Either place the maps in replicated storage or make the map on the server.

This discussion is preserved as it was. New answers, comments, and votes are closed.