Using this script I cant manage to Teleport a player properly to a part. The weird thing it’s that server-side the behavior is correct, but locally not, and that bothers me.
--Put the players on the ready team, put them on the grid too while being anchored
function PutPlayersOnGrid()
local readyPlayers = Teams.Ready:GetPlayers()
local success, errorMessage = pcall(function()
local clonedPlate: Model = ChooseSpawnPlate(#readyPlayers)
clonedPlate.Parent = workspace.Grid.PlatePositioner
clonedPlate:MoveTo(clonedPlate.Parent.Position)
local plateSpawnList = {}
for i, part: Part in pairs(clonedPlate:GetChildren()) do
if part.Name == "Spawn" then
table.insert(plateSpawnList, part)
local tempNEW = Instance.new("Part")
tempNEW.Parent = workspace
tempNEW.Position = part.Position
tempNEW.Anchored = true
end
end
--Discard players who died
for i, player: Player in pairs(readyPlayers) do
if player.Character.Humanoid.Health <= 0 then
player.Team = Teams.AFK
end
end
--Anchor all ready team players on the grid
--TODO
for i, player: Player in pairs(readyPlayers) do
local humanRoot: Part = player.Character.HumanoidRootPart
local humanoid: Humanoid = player.Character.Humanoid
humanRoot.Anchored = true
humanRoot.CFrame = plateSpawnList[i].CFrame
--player.Character:MoveTo(plateSpawnList[i].Position)
--local rotation = CFrame.Angles(0, math.rad(90), 0)
--local modelCFrame = player.Character:GetPivot()
--player.Character:PivotTo(modelCFrame * rotation)
--humanRoot.Position += Vector3.new(0, humanoid.HipHeight, 0)
--player.Character.HumanoidRootPart.CFrame = workspace.Grid.PlatePositioner.CFrame
LookModifierModule.SetSkatesOnLegs(player)
--Change character position a bit to not overlap with other players
local variationX = math.random(-22, 22)
local variationZ = math.random(-22, 22)
player.Character.HumanoidRootPart.Position += Vector3.new(variationX, 4.25, variationZ)
--Change character rotation to random
local variationR = math.random(-180, 180)
player.Character.HumanoidRootPart.Rotation = Vector3.new(0, variationR, 0)
end
end)
if success == true then
return true
else
warn(errorMessage)
return false
end
end
Here is the behavior serverside:
(Note that the wrong player rotation is not the problem, is expected, but the player appears in the center piece)
Here is the behavior clientside:
The player appears with a different rotation (vertically) and with an offset that I couldnt replicate between play tests. The player should appear on the center.
This bug is a game killer, I would appreciate any help. Thanks