Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

1 comment

0

thank you this is way easier then making and deleting a part

This discussion is preserved as it was. New answers, comments, and votes are closed.