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

Moving all players at once?

Any Ideas how to tell the game to find all players with the Players service and then moving their CFrame? Kinda new to using the Players service.

2 comments

2

Use a for loop to gather all players in the Player Service and access their characters to CFrame their torsos. We can not make the script for you otherwise it'd be a request.

0

I refreshed the question so its better

2 answers

✓ Accepted answer

Hello I understand you must be a novice scripter. I'm here to help.

-- So first you must gather the things you want or  get the children of the parent(the instance)
-- Instance(in this case is game.Players)
-- In order to keep track of the children we have to name them as a variable like this

local Children= game.Players:GetChildren()
-- Get children is a method to obtain every object that is inside a said instance such as Players

--Now we have to look though each child. We do that with    index,last Child  in pairs (Object) do
-- Like this

for i,v in pairs (Children) do
-- so I is the index meaning all of the Children and v is the child that the script is currently on.
-- so v replaces Children

v.Character:MoveTo(Vector3.new(1,1,1))
end


-- So v is the current child the script is on. Character is the character of the player
-- and to position Models you have to use the method :MoveTo(Vector3.new(x,y,z))
--

This script cycles through all players and moves their torso to a certain position

for _, player in pairs(game.Players:GetPlayers())do --cycles through every "player" in Players
if player then
	local character = player:FindFirstChild("Character")
		if character then
			character.Torso.CFrame = CFrame.new()
		end
	end
end
			

1 comment

0

It's not necessary to check "if player" and your indentation is wrong.

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