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

This script should teleport every player in the server. But it kills them after they teleport. Why?

Asked by
gmod419 23
6 years ago
Edited 6 years ago
wait(5)
print("ready")
wait(1)

local TeleportPosition = Vector3.new(107.5, 9, -5)

for i, v in pairs(game.Players:GetPlayers()) do
    Humanoids = v.Character:GetChildren()
    for i, v in pairs(Humanoids) do
        if v.ClassName == "MeshPart" or v.ClassName == "Pants" or v.ClassName == "Shirt" or v.ClassName == "Part" then
            v.Position = TeleportPosition
        end
    end
end

So this teleports every player in the server to a specific location. Why does it kill them? https://youtu.be/rZSavbAGVuU Video Above For Example

1 answer

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

That's because what you actually do is iterate thru every part inside a character and put all of them in one location and also compressing them. If you move the head or a torso out of a character, it breaks the welds of the whole character, causing one to die.

What you can do instead is teleport just the HumanoidRootPart of each character so that none of the joints would break.

wait(5)
print("ready")
wait(1)

local TeleportPosition = CFrame.new(107.5, 9, -5)

for i, v in pairs(game.Players:GetPlayers()) do
    Humanoids = v.Character
    Humanoids.HumanoidRootPart.CFrame = TeleportPosition
end
0
I thought this was the right idea, and Ive tried this. Theres still a problem. When I do this my character disappears. Im uploading a video right now. gmod419 23 — 6y
0
woopsies got it wrong try using cframes, will edit answer noposts 75 — 6y
0
Thanks so much, Also if u want could you find a tutorial on youtube thats about cframes Im sorta impressed. :/ gmod419 23 — 6y
View all comments (2 more)
0
i don't really know if there's actual good videos in youtube about cframes, but there are a lot of good tutorials in the wiki about them. if you want a detailed one then: http://wiki.roblox.com/index.php?title=User:EgoMoose/Articles/CFramesAndVectors noposts 75 — 6y
0
Thanks gmod419 23 — 6y
Ad

Answer this question