Description
model:PivotTo() does not work on anchored R6 characters, but works on anchored R15 characters.
Reproduction pivotto_bug.rbxl (74.2 KB)
Place file above contains a blue brick which teleports the player back to spawn. Works when setting avatar settings to R15 only, does not work when setting avatar settings to R6 only. Remove the anchoring code and it works for both.
local debounce = false
script.Parent.Touched:Connect(function(otherPart: BasePart)
local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if player and not debounce then
warn("teleporting...")
debounce = true
task.delay(1, function()
debounce = false
end)
player.Character.PrimaryPart.Anchored = true
player.Character:PivotTo(workspace.SpawnLocation.CFrame)
player.Character.PrimaryPart.Anchored = false
end
end)
Additional Info:
This only occurs with parts that aren’t the root of the assembly, anchoring any non-root part of the assembly seems to stop position/cframe replication.
@nosgnal As a work-around, anchor R6 characters by their AssemblyRootPart (typically the HumanoidRootPart).
Thanks, the workaround works. I found the discrepancy here is that in R6 PrimaryPart point to Head while in R15 it points to HumanoidRootPart.
Additional Info:
This only occurs with parts that aren’t the root of the assembly, anchoring any non-root part of the assembly seems to stop position/cframe replication.
I wonder if this is intentional or not. To me the semantics of anchoring should only prevent physics-based movement, not a CFrame change.
Updated code:
local debounce = false
script.Parent.Touched:Connect(function(otherPart: BasePart)
local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if player and not debounce then
warn("teleporting...")
debounce = true
task.delay(1, function()
debounce = false
end)
player.Character.HumanoidRootPart.AssemblyRootPart.Anchored = true
player.Character:PivotTo(workspace.SpawnLocation.CFrame + Vector3.new(0, 3, 0))
player.Character.HumanoidRootPart.AssemblyRootPart.Anchored = false
end
end)