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

I need help with this map changing script, that wont work with teleporting, can someone help me?

Asked by 6 years ago

So I have this script its below

Maps = {"ZombieFacility"} -- can add as many maps as you want intermission = 15 -- intermission time gamewait = 60 -- each round length numofplayers = 1 -- How many players are required to start a round timebeforeround = 5 --Time before round starts

wait(5) function m(update) c = game.Players:GetChildren() for i=1, #c do c[i].PlayerGui.InformationGui.Frame.TextLabel.Text = "" .. update end end

while true do wait(1) if game.Players.NumPlayers >= numofplayers then

for i=1, intermission do
    m("Intermssion: " .. intermission -i)
    wait(1)
end

pl = game.Players:GetChildren()

for i=1, #pl do
    pl[i].Playing.Value = true
end


rndum = math.random(#Maps)
cmap = Maps[rndum] -- This picks a random map

game.Lighting[cmap]:Clone().Parent = game.Workspace

m("Picking a map ...")
wait(2)
m("The chosen map is " .. cmap)
wait(2)

plpl = game.Players:GetChildren()

for i=1, #plpl do
if plpl[i].Playing.Value == true then
    cspawn = game.Workspace[cmap].Spawns.Spawn
    plpl[i].Character.Torso.CFrame = CFrame.new(cspawn.Position)

Its really long and theres more that I didnt put on but right here on the bottom it says cant find Torso in Model, I have no idea why can someone help me?

0
And now Roblox Studio keeps crashing why? protectiverobos -50 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

You didn't post any real error messages, but you either aren't waiting for the player's character and it's children to load in or you're looking for the wrong RigType parts. R6 contains the part named Torso while R15 has UpperTorso and LowerTorso. To get around this without locking the game to either RigType, I'd just look for the HumanoidRootPart. See if this works:

local cspawn = game.Workspace[cmap].Spawns.Spawn
game.Players.PlayerAdded:connect(function(pl)
    pl.CharacterAdded:connect(function(cha)
        local hum = cha:WaitForChildOfClass("Humanoid")
        local torso = nil
        if hum.RigType == Enum.HumanoidRigType.R6 then
            torso = cha:FindFirstChild("Torso")
        else
            torso = cha:FindFirstChild("UpperTorso")
        end
        torso.CFrame = CFrame.new(cspawn.Position) 
    end)
end)
0
Ok now it doesnt give me the error message but it doesnt teleport me to the map, do you know why? protectiverobos -50 — 6y
0
Add debugs(print statements) in between to see if you got an error. Meltdown81 309 — 6y
Ad

Answer this question