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

How do I fix this player teleportation to the map ?

Asked by 8 years ago

I have tried to teleport the player to the map after the intermission counts down to zero but the map spawns and the player doesn't get teleported. Not sure where the error is.

local replicatedstorage = game:GetService('ReplicatedStorage')
local status = replicatedstorage:WaitForChild('InfoValue')
?
local mapstorage = game.Workspace:WaitForChild('MapStorage')
?
?
while true do
?
--[[
while game.Players.NumPlayers < 2 do
 status.Value = 'There Needs To Be 2 Or More Players To Begin'
 repeat wait(2)until game.Players.NumPlayers >= 2
end
?
]]
?
?
for i = 30,0,-1 do
 status.Value = 'Intermission: '..i
--In the 15 seconds remaining for intermission have the map voter gui
 wait(1)
end
?
?
local mapsinserverstorage = game:GetService('ServerStorage'):GetChildren()
local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
--chosenmap:Clone().Parent = game.Workspace
chosenmap:Clone().Parent = mapstorage
status.Value = "Get Ready to Fight!"
wait(3)
?
?
local spawns = chosenmap:WaitForChild('Spawns'):GetChildren()
for _, player in pairs(game.Players:GetPlayers()) do
    if player and #spawns > 0 then 
        local torso = player.Character:WaitForChild('Torso')
        local allspawns = math.random(1, #spawns)
        local randomspawn = spawns[allspawns]
        if randomspawn and torso then
            table.remove(spawns, allspawns)
            torso.CFrame = CFrame.new(randomspawn + Vector3(0,2,0))

            local sword = game.ReplicatedStorage.woodSword
            local newSword = sword:Clone()
            newSword.Parent = player.Backpack

        end
    end
end
?
?
?
?
wait(30)
?
?
?
?
mapstorage:ClearAllChildren()
end

1 answer

Log in to vote
0
Answered by 8 years ago
local replicatedstorage = game:GetService('ReplicatedStorage')
local status = replicatedstorage:WaitForChild('InfoValue')
?
local mapstorage = game.Workspace:WaitForChild('MapStorage')
?
?
while true do
?
--[[
while game.Players.NumPlayers < 2 do
 status.Value = 'There Needs To Be 2 Or More Players To Begin'
 repeat wait(2)until game.Players.NumPlayers >= 2
end
?
]]
?
?
for i = 30,0,-1 do
 status.Value = 'Intermission: '..i
--In the 15 seconds remaining for intermission have the map voter gui
 wait(1)
end
?
?
local mapsinserverstorage = game:GetService('ServerStorage'):GetChildren()
local chosenmap = mapsinserverstorage[math.random(1, #mapsinserverstorage)]
--chosenmap:Clone().Parent = game.Workspace
chosenmap:Clone().Parent = mapstorage
status.Value = "Get Ready to Fight!"
wait(3)
?
?
local spawns = chosenmap:WaitForChild('Spawns'):GetChildren()
for _, player in pairs(game.Players:GetPlayers()) do
    if player and #spawns > 0 then 
        local torso = player.Character:WaitForChild('Torso')
        local allspawns = math.random(1, #spawns)
        local randomspawn = spawns[allspawns]
        if randomspawn and torso then
            table.remove(spawns, allspawns)
            torso.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0)) --Forgot to put randomspawn.Position and Vector3.new

            local sword = game.ReplicatedStorage.woodSword
            local newSword = sword:Clone()
            newSword.Parent = player.Backpack

        end
    end
end
?
?
?
?
wait(30)
?
?
?
?
mapstorage:ClearAllChildren()
end


Ad

Answer this question