I'm using a local script to move both the local player's character and other players' characters. To do this, I'm changing the position of their humanoid root part. For some reason, this only works with the local player's character, while other player's humanoid root parts are teleported but the characters are left behind.
char.HumanoidRootPart.Position = tileGrid:FindFirstChild("PlayerStart"..playerInt.Value).Position + Vector3.new(0,8,0)
This is the bit that moves the local player's root part.
for i,v in pairs(Players:GetChildren()) do --creates a clientside model of other players already in the game if v:WaitForChild("PlayerInteger").Value ~= playerInt.Value then print() if otherPlayer1 == nil then game.workspace:WaitForChild(v.Name).HumanoidRootPart.Position = tileGrid:FindFirstChild("PlayerStart"..otherPlayerInt1.Value).Position + Vector3.new(0,8,0) end end end
And this is the bit that teleports the root part of the other player. Note that the root part is teleported fine, only the character is left behind. Also, whenever I animate the other character's root part (the animation is a simple arc to make the character look like they are jumping) later in the script, the character moves up and down with the root part, although it is in the wrong position because it didn't teleport initially.
I'm wondering if this is just a bug of trying to use local scripts to manipulate other players' characters other than the local player, and if there are any workarounds to this. Or maybe something is wrong with my code. Hope somebody has an idea
EDIT: I cut the question down to just the bare essentials of what I'm asking
A local script is unable to teleport every player. Here's why.
A client has full control over its character and that control can only be overridden by the server. A local script enables to client to:
If you want to teleport every player and not just one player, leave that to the server. A client cannot teleport every player because of FE, but it can teleport its own character to wherever it pleases.
If you are going to use SetPrimaryPartCFrame()
instead of Move()
(although both work), first check to make sure that the PrimaryPart
isn't assigned to nil:
if Character.PrimaryPart then
If the condition passes, that means that there is a part assigned to PrimaryPart
. You can then proceed to use the method:
Character:SetPrimaryPartCFrame(CFrame.new(0,0,0)) -- Insert a CFrame here
If you do decide to use the method, take note of the following things: