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

Why does the teleport just fling me to the wall instead of teleport the player downwards?

Asked by
Z0ggg 20
5 years ago

Ok, so i have a round script (I cut out the parts irrelevant to teleporting, like equipping the player) and before the round starts it is supposed to teleport the players to a random spawn point on the map (downwards of the lobby).

pos1 = Vector3.new(game.ServerStorage.spawns.spawn1.Position)
pos2 = Vector3.new(game.ServerStorage.spawns.spawn2.Position)
pos3 = Vector3.new(game.ServerStorage.spawns.spawn3.Position)
pos4 = Vector3.new(game.ServerStorage.spawns.spawn4.Position)
pos5 = Vector3.new(game.ServerStorage.spawns.spawn5.Position)
pos6 = Vector3.new(game.ServerStorage.spawns.spawn6.Position)

positions = {pos1,pos2,pos3,pos4,pos5,pos6}
TIME = 30 -- default
hint = game.Workspace.Hint
maps = game.ServerStorage.maps:GetChildren()

while true do
    while true do
        wait(1)
        hint.Text = "The round starts in "..tostring(TIME).." seconds..."
        TIME = TIME - 1
        if TIME == 0 then
            hint.Text = "Picking and loading map..."
            wait(3)
            picked = maps[math.random(1,#maps)]
            hint.Text = "Chosen map is "..picked.Name..". Get ready."
            wait(3)
            clone = picked:Clone() clone.Parent = workspace
            plrs = game.Players:GetChildren()
            TIME = 60
            wait(1)
            break
        end
    end
    --teleport players here
    for i,v in pairs(plrs) do
        print("equipping and teleporting")
        equip(v)
        ran = positions[math.random(1,#positions)]
        v.character.Torso.CFrame = CFrame.new(ran)
    end
    --stops teleporting players and starts round.
    while true do
        wait(1)
        hint.Text = "Fight! The round ends in "..tostring(TIME).." seconds..."
        TIME = TIME - 1
        if TIME == 0 then
            hint.Text = "Round ending and teleporting players back..."
            clone:Destroy()
            wait(3)
            break
        end
    end
    TIME = 30
end

I haven't added a teleport back function yet because the script messes up while teleporting the player to one of the spawn positions. Instead of putting each player in the random selected spot the script teleports me to the East of the lobby, the wrong way from the downwards spot on the map. I've messed around with it some and can't seem to find the cause of this, it would lovely if someone can help because my little knowledge about Roblox CFrame.

0
Line 36, you are doing CFrame.New(Vector3.New(blabla)) I don't know if it's just the way you prefer to do it, or what, but I think that you can skip it and head directly to game.Serverstorage(...) unsure if I'm helping at all, but worth trying. dionant 23 — 5y
0
CFrame will require me to put a Vector3.New no matter where i put it :/ Z0ggg 20 — 5y

Answer this question