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

How would i store all of the players in the games CFrame?

Asked by 6 years ago

I have no clue on how i'd make a script that stores all of the players CFrames every 30 seconds and then when i clicked a key, it would change there CFrames to what they were 30 seconds ago. How would i store all the CFrame values is really what im trying to ask.

1 answer

Log in to vote
0
Answered by
theCJarmy7 1293 Moderation Voter
6 years ago

There are actually a couple ways to do this, but I'll just be explaining one here. Personally, I would keep their Cframe in a table, and then refer to that table when I need to teleport them back.

local function getAllCFrames()
    local cframes = {}
    for i,v in pairs(game.Players:GetChildren()) do --loop through all players
        if v.Character then --if they actaully have a character
            local cf = v.Character:FindFirstChild("HumanoidRootpart").CFrame
            -- I'm not too sure on the capitalization for /\
            cframes[tostring(v.Name)] = cf
            -- store's the players cframe in the table, with it's index being the player's name
        end
    end
    return cframes
end

And there you go, a table full of all the player's CFrame values, simply loop through that table and teleport the player to that position when you want.

0
thank you this is way easier then making and deleting a part ATestAccount420 31 — 6y
Ad

Answer this question