Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Map Load Script - Convert from linerar to Random?

Asked by 8 years ago

Hey guys!

So I have a linear map script, so all my tracks run in order. I however want to change it so that it loads the tracks at random. Does anyone have a method for me to change it?

Delay = 10
ZombieAttackTime = 45 -- This was a Freemodel, but heavily modified for what I need now. Never really changed this variable

function hint(text,time) --Hint Function
    local Message = Instance.new("Hint",workspace)
    Message.Text = text
    game:GetService("Debris"):AddItem(Message, time) --Add Item from Debris service
end

function message(text,time) --Message Function
    local msg = Instance.new("Message",workspace)
    msg.Text = text
    game:GetService("Debris"):AddItem(msg, time)--Same thing
end


while true do

    for i = Delay,0,-1 do --Changed this to this format
        hint("The Next Race will begin in " .. i .. " seconds", 1) --Changed the hints into functions
        wait(1)
        end
    message("Course: Original by Michael007800", 4.5)--Same thing with messages
wait(5)
    message("The race will start soon!", 3)
    game.Lighting.Map1:clone().Parent = game.Workspace
    game.Workspace.Teleport:remove()
    game.Workspace.Lobby:remove()
wait(15)
    game.Lighting.Lobby:clone().Parent = game.Workspace
    game.Workspace.Lights.Sequence.Script.Disabled = false
wait(6)
    script.Sound1:play()
    script.RaceStart1:play()
    script.RaceStart2:play()
    script.RaceStart3:play()
    script.RaceStart4:play()
    script.RaceStart5:play()
    script.Parent.CanCollide = false
    script.Parent.Transparency = 1
    script.Parent.Decal.Transparency = 1
    wait(5)
    script.Parent.Decal.Transparency = 0
    script.Parent.CanCollide = true
    script.Parent.Transparency = 0
    game.Lighting.Teleport:clone().Parent = game.Workspace
        for i = 1, ZombieAttackTime*1 do
            hint("The race will end in " .. (ZombieAttackTime-i) .. " seconds", 1)
        wait(1)
    end
    message("THE RACE HAS ENDED!!!!!", 3)
    game.Workspace.Map1:Destroy()
    script.Sound1:stop()
    script.Parent.CanCollide = true
    script.Parent.Transparency = 0
wait(3)
    script.NoRace:Play()

Cheers guys!

Michael

0
Wait, how would the map change at all? It looks to me on line 26 that you're loading the same one each time. Perci1 4988 — 8y
0
I have multiple maps, Just showing one for spacewise. Michael007800 144 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

You were only calling on 1 map to be cloned, Map1, which explains why it keeps picking the same exact map. I added in 2 extra lines that will pick a random map from the selected list of maps. All you have to do is edit Line1 and put the name of your maps!

local mapsUsed = {"Put Your Map Names Here", "And Here!"} --Put map names here
Delay = 10
ZombieAttackTime = 45 -- This was a Freemodel, but heavily modified for what I need now. Never really changed this variable

function hint(text,time) --Hint Function
    local Message = Instance.new("Hint",workspace)
    Message.Text = text
    game:GetService("Debris"):AddItem(Message, time) --Add Item from Debris service
end

function message(text,time) --Message Function
    local msg = Instance.new("Message",workspace)
    msg.Text = text
    game:GetService("Debris"):AddItem(msg, time)--Same thing
end


while true do

    for i = Delay,0,-1 do --Changed this to this format
        hint("The Next Race will begin in " .. i .. " seconds", 1) --Changed the hints into functions
        wait(1)
        end
    message("Course: Original by Michael007800", 4.5)--Same thing with messages
wait(5)
    message("The race will start soon!", 3)
    local mapPicked = mapsUsed [math.random(1,#mapsUsed )]
    game.Lighting:FindFirstChild(mapPicked):Clone().Parent = game.workspace --ADDED CODE
    game.Workspace.Teleport:remove()
    game.Workspace.Lobby:remove()
wait(15)
    game.Lighting.Lobby:clone().Parent = game.Workspace
    game.Workspace.Lights.Sequence.Script.Disabled = false
wait(6)
    script.Sound1:play()
    script.RaceStart1:play()
    script.RaceStart2:play()
    script.RaceStart3:play()
    script.RaceStart4:play()
    script.RaceStart5:play()
    script.Parent.CanCollide = false
    script.Parent.Transparency = 1
    script.Parent.Decal.Transparency = 1
    wait(5)
    script.Parent.Decal.Transparency = 0
    script.Parent.CanCollide = true
    script.Parent.Transparency = 0
    game.Lighting.Teleport:clone().Parent = game.Workspace
        for i = 1, ZombieAttackTime*1 do
            hint("The race will end in " .. (ZombieAttackTime-i) .. " seconds", 1)
        wait(1)
    end
    message("THE RACE HAS ENDED!!!!!", 3)
    game.Workspace.Map1:Destroy()
    script.Sound1:stop()
    script.Parent.CanCollide = true
    script.Parent.Transparency = 0
wait(3)
    script.NoRace:Play()

0
There are more maps in the actual script. I'm showing one for space. Michael007800 144 — 8y
0
I see, but this would still work for that occasion too. User#9949 0 — 8y
Ad

Answer this question