tarrdoJoin Date: 2008-06-24 Post Count: 476 |
while true do
wait() --you need this, otherwise roblox will crash
function MapSelector (Lighting, Workspace)
a = math.random (1,3)
if a == 1 then
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Loading Map: Havoc") -- Upcoming Map Name
wait(4)
msg:remove()
game.Lighting.Map1:clone().Parent = game.Workspace
wait(20) -- Time between map changes
wait(4)
game.Workspace.Map1:remove()
game.Lighting.FogEnd = 100000 -- removes fog from map
wait (1)
else if a == 2 then
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Loading Map: Desert Troop") -- Upcoming Map Name
wait(4)
msg:remove()
game.Lighting.Map2:clone().Parent = game.Workspace
wait(20) -- Time between map changes
wait(4)
game.Workspace.Map2:remove()
wait (1)
else if a == 3 then
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Loading Map: Harbor") -- Upcoming Map Name
wait(4)
msg:remove()
game.Lighting.Map3:clone().Parent = game.Workspace
wait(20) -- Time between map changes
wait(4)
game.Workspace.Map3:remove()
wait (1)
end
end
end
end
end
I know I am missing something and it's probably obvious.
I want my script to scroll through these maps at random(for now) and it doesn't even select a map in the first place.
Ignore the fact that I have the maps on for 20 seconds each that is for testing purposes. |
|
|
Are you executing the function MapSelector()?. |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
Well it isn't on disabled so I have no idea, I'm a beginner scripter |
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
ah the days i was so inefficient |
|
|
this isnt even ur script lol |
|
|
This script is not a very good script because it will be hard to add maps in the future. So I am not going to show you the error, but re-write the script.
local maps={game.Lighting:findFirstChild("Harbor"), game.Lighting:findFirstChild("Desert Troop")} --You add more
local map
chooseMap=function()
local seed=math.random(1, #maps)
local map=maps[seed]
return (map)
end
notifyMapLoad=function(mapName)
local msg=Instance.new("Message", workspace)
msg.Parent=Workspace
msg.Text=("Loading Map:" mapName)
game.Debris:AddItem(msg, 4)
end
spawnMap=function(map)
local clone=map:Clone()
clone.Parent=workspace
notifyMapLoad(clone.Name)
end
removeMap=function(map)
map:remove()
end
while (true) do
wait()
map=chooseMap()
spawnMap(map)
wait(50)
removeMap(map)
end |
|
|
Sorry for any errors/typos, I wrote this directly on the forum. Good luck ;) |
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
game.ServerStorage:findFirstChild("Map"..map)
... |
|
|
Well I'm sorry, I learned before roblox added that. |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
@Nice coder, this is my script the script I had before was linear and spawned the maps in order, I rewrote it to have the maps be random, but thank you for being rude, go somewhere else if you're going to be toxic and judgmental |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
The maps are actually named Map1 Map2 Map3 inside lighting cause it was easier to line them up originally that way. |
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
You don't need an if statement checking the number.
My map chooser doesn't have any if statements. |
|
|
> inside lighting
Roblox is moving away from storing things in lighting.
Store things in ServerStorage.
I hate the LGBT. Those laser guided battle tanks are just too damn powerful. |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
That signature (thumbs up) |
|
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
Don't even use if |
|
|
Did my script work for you? |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
So smiley essentially you are saying this is what it should look like
function MapSelector (ServerStorage, Workspace)
a = math.random (1,3)
a = 1
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Loading Map: Havoc") -- Upcoming Map Name
wait(4)
msg:remove()
game.ServerStorage.Map1:clone().Parent = game.Workspace
wait(20) -- Time between map changes
wait(4)
game.Workspace.Map1:remove()
game.Lighting.FogEnd = 100000 -- removes fog from map
wait (1)
a = 2
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Loading Map: Desert Troop") -- Upcoming Map Name
wait(4)
msg:remove()
game.ServerStorage.Map2:clone().Parent = game.Workspace
wait(20) -- Time between map changes
wait(4)
game.Workspace.Map2:remove()
wait (1)
a = 3
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Loading Map: Harbor") -- Upcoming Map Name
wait(4)
msg:remove()
game.ServerStorage.Map3:clone().Parent = game.Workspace
wait(20) -- Time between map changes
wait(4)
game.Workspace.Map3:remove()
wait (1)
end
end
And if so how does it know if a selected 1,2,3 without the if statements being there, it sounds like you want me to load all 3 maps at once. |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
Airsoft I will try your script out but I prefer to use my own, if it works I will let you know if not and I can fix it I will fix it and post it here. :) |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
Your script doesn't work, nor do I have any knowledge of scripting that could help you, my scripts are big and sloppy the way I like them and understand them. :) |
|
fajner1Join Date: 2008-03-30 Post Count: 77 |
Big, sloppy, linear scripts are often easier to make when diving right in, but if you try to convert the major part into a function, it might help you find the error (not to mention improve expandability). The three large blocks of code are identical to each other except for the name and location of the map. If you wanted to change the wait times, for example, you would have to go into each blocks and change them, but if you turn it into a function, you only have to do it once.
/*
function nextMap(mapName, mapLocation)
print("[Debug] Map "..mapName.." loaded")
local msg = Instance.new("Message")
msg.Parent = game.Workspace
msg.Text = ("Loading Map: "..mapName) -- Upcoming Map Name
wait(4)
msg:remove()
local map = mapLocation:clone()
map.Parent = game.Workspace
wait(24) -- Time between map changes
map:remove()
game.Lighting.FogEnd = 100000 -- removes fog from map
wait (1)
end
while true do
wait()
local choice = math.random(1,3)
if choice == 1 then nextMap("Havoc", game.ServerStorage.Map1)
elseif choice == 2 then nextMap("Desert Troop", game.ServerStorage.Map2)
elseif choice == 3 then nextMap("Harbor", game.ServerStorage.Map3)
end
end
*/ |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
It didn't work, no error it just never selected a map in the first place. Maybe if I give you my original map script and we just tweak it to randomly select a map instead of trying to make a new script. |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
Ignore that your script did work but I had my script deactivated, though I only noticed it was deactivated when I rewrote my script to ensure it would work and added print scripts and since nothing printed I knew it was off I have a working script that I made and even if it is sloppy im keeping it for the sake of having it my own. |
|
smiley599Join Date: 2010-01-23 Post Count: 21869 |
Stop using if statements u nobs |
|
tarrdoJoin Date: 2008-06-24 Post Count: 476 |
Stop using if statements u nobs
Friends: 4
Forum Posts: 18,357
Place Visits: 0
Knockouts: 6,494
Highest Ever Voting Accuracy: 79%
I don't think you bothered to read what I had said but I did remove the if statements and it doesn't work, so how about you and your 0 place visits with your pro scripting skills shove it? |
|