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

Why does this function not teleport? It doesn't return any errors?

Asked by 6 years ago
Edited 6 years ago

I'm puzzled as to why this doesn't work. in theory it should. Did I do something wrong? It get's inside the function, because the client is displaying "Teleporting Players...".

timeRemote = game.ReplicatedStorage.timeExchange
statusRemote = game.ReplicatedStorage.statusExchange
advantageRemote = game.ReplicatedStorage.advantageExchange




function choseGameMode()
    statusRemote:FireAllClients("Choosing gamemode... please wait.")
    pickedGameMode = gameModes[math.random(1,#gameModes)]
    statusRemote:FireAllClients(("The chosen gamemode is "..pickedGameMode.."!"))

end

function spawnGameMode()

    if pickedGameMode == "GameMode1" then
        --GameMode1 spawn
        local gameMode1Map = game.ServerStorage.GameMode1:Clone()
        gameMode1Map.Parent = game.Workspace


    elseif pickedGameMode == "GameMode2" then
        --GameMode2 spawn
        local gameMode2Map = game.ServerStorage.GameMode1:Clone()
        gameMode2Map.Parent = game.Workspace


    elseif pickedGameMode == "GameMode3" then
        --GameMode3 spawn
        local gameMode2Map = game.ServerStorage.GameMode1:Clone()
        gameMode2Map.Parent = game.Workspace
    end



end

function advantagePlayer()
    statusRemote:FireAllClients("Choosing Player to give an advantage to...")
    for i=1,#alive do

        if alive[i] == pickedPlayer then
            advantageRemote:FireClient(alive[i],"Shh... You have the Advantage!")
        else
            advantageRemote:FireClient(alive[i],"You don't have the Advantage, maybe next time.")
        end
    end
    wait(3)
    for i=1,#alive do
            advantageRemote:FireAllClients(" ") 
    end

end

function teleportPlayers()
    statusRemote:FireAllClients("Teleporting Players...")
    if pickedGameMode == "GameMode1" then
        --GameMode1 teleport
        for i=1, #alive do
        print("1")
        alive[i].Character:MoveTo(Vector3.new(math.random(50,150), 108, math.random(150,250)))

        end


    elseif pickedGameMode == "GameMode2" then
        --GameMode2 teleport
        for i=1, #alive do
        print("1")
        alive[i].Character:MoveTo(Vector3.new(math.random(50,150), 108, math.random(-150,-250)))

        end


    elseif pickedGameMode == "GameMode3" then
        --GameMode3 teleport
        for i=1, #alive do
        print("1")
        alive[i].Character:MoveTo(Vector3.new(math.random(-50,-150), 108, math.random(-150,-250)))

        end
    end


end


while true do
    wait(4)
    if #game.Players:GetChildren() < 4 then --CHECK FOR PLAYERS

    --VARIABLES
    players = game.Players:GetChildren()
    alive = players
    pickedPlayer = players[math.random(1,#players)]
    gameModes = {
        "GameMode1",
        "GameMode2",
        "GameMode3"
    }
    --VARIABLES
    teleportPlayers()






    end
end

Side Question: Is there a way I can optimize this instead of just checking for the value of the picked gamemode?

0
The truth is that it is difficult to help you this incomplete script and what are the variables Alive models? Do you have the script on it? brok4d 77 — 6y
0
edited the post to include the whole script. MezornoIV 25 — 6y
0
It has an end at the end of the line of in while brok4d 77 — 6y
0
That was an error, there is no end in the script. MezornoIV 25 — 6y
View all comments (5 more)
0
The class gamemodes that are in ServerStorage? brok4d 77 — 6y
0
If you're referring about the table of gamemodes I have defined, they are only referenced in the scripts. The object or models I want to clone are in ServerStorage. MezornoIV 25 — 6y
0
So what do you want to clone all the models at the same time of the ServerStorage? brok4d 77 — 6y
0
I've figured it out, nevermind. MezornoIV 25 — 6y
0
The spawnGameMode () function you never call. brok4d 77 — 6y

Answer this question