I’ve been doing some research and ive found that you pratically need to use a loop but then i need to put them under a variable which i need to pass down through a remote event and am not able to do that for some reason.
Hi, there are multiple ways you could get around this but could you tell me what you trying to do with all that player data?
Hey, im trying to TP all the players to a certain position and use change their Camera Cframe for a cutscene
Can’t you do?:
for _,Player in game:GetService("Players"):GetPlayers() do
end
:GetPlayers()
returns a table of all players in the server.
I am able to get that table of all players in the server already but im not able to get their character model
You can get their character though.
for _,Player in game:GetService("Players"):GetPlayers() do
local Character = Player.Character
end
and for the camera changes you can just fire an event to all clients:
Event:FireAllClients("Cutscene")
You can follow these steps if your are familiar with the basics of player manipulation and remote functions:
-
Collect Player Data: You need to gather the characters of all players in the server. This can be done using a loop that goes through
Players:GetPlayers()
. -
Teleport Players: To teleport each player, you’ll want to set their character’s position to a specific location. This is done by modifying the character’s PrimaryPart, usually the
HumanoidRootPart
, with a new position using CFrame. Make sure to set this PrimaryPart correctly in all the player character models. -
Adjust Camera CFrame: Since the camera is unique to each player, you’ll need to send the new camera position (CFrame) to each client. This allows you to control how each player views the cutscene, ensuring that it syncs up for everyone. Since you can’t manipulate clients’ cameras directly from the server, you’ll use a RemoteEvent. This allows the server to communicate with the clients and tell them to adjust their camera CFrame based on the desired cutscene setup.
-
Cutscene Execution: When you’re ready to start the cutscene, fire all the clients from the server which will trigger all the client connected to the remote event.
Let me know if you need further clarification or if you don’t understand how to do a step.
Oh yeah i couldnt get it since i was using a non performant way of getting all players, thank you!
For some reason, i keep getting an error or not getiing teleported at all when trying to do so. Would you have an exemple on how to change the CFrame to make sure im not doing it wrong please?
The character part should be done serversided, but the client should handle their own camera
Okay, i found a solution but it is honestly pretty confusing as i had to get Player.Character.Character for some reason?
If you have the player object and character object already inside the player loop, you can access the primary part of the character using character.PrimaryPart
, you can then set the CFrame of that primary part to move the character to the new location, here’s a very easy example:
for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
local character = player.Character or player.CharacterAdded:Wait()
if character and character.PrimaryPart then
character.PrimaryPart.CFrame = targetCFrame
else
warn("PrimaryPart not found for player: " .. player.Name)
end
end
You should be doing it like this
for _,player in game:GetService("Players"):GetPlayers() do
local character = player.Character
character.HumanoidRootPart.CFrame = Part.CFrame
Event:FireClient(Player,"Cutscene")
end
you could use a remotefunction and send it from the server and the client sends back the camera info
Okay yeah, i tried doing something similar and i put it in the ServerScript and it worked, seems like this also works for players who have not loaded in yet too, Thanks! I’ll update if i face other issues with the camera thing