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

How can I get the script to check a random model from ServerStorage?

Asked by 10 years ago
-- NinjoOnline --

map = game.ServerStorage.Maps:GetChildren()

h = Instance.new("Hint", game.Workspace)

while true do

--------------------------
-- Random map is chosen --
--------------------------  

    if game.Players.NumPlayers > 1 then
        h.Text = "Deciding what map to play"
        wait(5)
        ranMap = math.random(1, #map)
        mapChosen = map[ranMap]
        h.Text = "Map Chosen: " .. mapChosen.Name
        wait(3)
        mapChosenClone = mapChosen:Clone()
        mapChosenClone.Parent = game.Workspace.MapHolder
        wait(2)

-------------------------
-- Picks random killer --
-------------------------

        players = game.Players:GetChildren()
        local randomp = players[math.random(1,#players)]
        print(randomp.Name .. " is killer")
        randomp.TeamColor = BrickColor.new("Bright red")
        for i,v in pairs(players)  do
            if v.Name ~= randomp.Name then
                print(v.Name .. " is runner")
                v.TeamColor = BrickColor.new("Bright blue")
            end
        end

---------------------------------
-- Teleport players to the map --
---------------------------------

        rspawn = mapChosenClone.RunnerSpawn:GetChildren()
        kspawn = mapChosenClone.KillerSpawn:GetChildren()

        for i,v in pairs(game.Players:GetChildren()) do
            name = v.Name
            check = game.Workspace:FindFirstChild(name)
            check:MoveTo(rspawn[i].Position)
        end



---------------------------
-- Round begins countdown --
---------------------------

        for i = 3, 1, -1 do
            h.Text = "Game begins in: " .. i
            wait(1)
        end

-------------------------------
-- Countdown till round ends --
-------------------------------

        for i = 10, 1, -1 do
            h.Text = "Time left: " .. i
            wait(1)
        end
        h.Text = "The round has ended"
        wait(1)

------------------------------------        
-- Teleport players back to lobby --
------------------------------------

        for i,v in pairs(game.Players:GetPlayers()) do
            v.Character:MoveTo(Vector3.new(108, 11.19, -29))
        end
        wait(1)

---------------------
-- Destroy the map --
---------------------

        mapChosenClone:Destroy()

--------------------------------------------------
-- Needs to be 1 more player for round to begin --
--------------------------------------------------

    else
        h.Text = "You need 1 more player to join"
    end
    wait(1)
end






--[[
play = game.Players:GetChildren() 
    for i = 1,#play do 
    if p[i] ~= nil then
        if play[i].TeamColor == game.Teams.Runners.TeamColor then 
            play[i].Character.Humanoid.WalkSpeed = 0
            char = play[i].Character
            if char ~= nil then 
                torso = char:findFirstChild("Torso") 
                if torso ~= nil then 
                    torso.CFrame = game.Workspace.MapHolder.(CHOSEN MAP)RunnerSpawn.CFrame + Vector3.new(math.random(-6, 6), 0, math.random(-6, 6))
                    wait(0.025)
                end 
            end 
        end
    end 
end 
 ]]

Where it says (CHOSEN MAP) {LINE 114} I need it to be like a string or something that will be the randomly chosen map. Anyone know how I could manipulate a string into that part

0
So pretty much I'm asking. I have it already pick a random map, and it takes it from serverstorage and puts it in "MapHolder" in workspace, but it puts it in the MapHolder as the model, I need the map ungroued when it goes to MapHolder. How can I do that? NinjoOnline 1146 — 10y

Answer this question