Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Roblox "Position cannot be assigned to" error?

Asked by 2 years ago

So, I have a script that is supposed to teleport a player to a certain position once they die. However, I am getting a "Position cannot be assigned to" error. Here is the code:

local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild("Humanoid") then
    while wait(0.1) do
        while wait(0.1) do -- I have 2 loops to make it go a lot longer
            if player.Character.Humanoid.Health == 0 then
                wait(6)
                player.Character.HumanoidRootPart.CFrame.Position = Vector3.new(1, 2, 3)
            end
        end
    end
end

Thanks in advance for any help!

1 answer

Log in to vote
0
Answered by 2 years ago

Just do:

player.Character.HumanoidRootPart.Position = Vector3.new(1, 2, 3)

instead of:

player.Character.HumanoidRootPart.CFrame.Position = Vector3.new(1, 2, 3)
0
Thanks, but no thanks. When I try that, it only teleports the HumanoidRootPart (which the Character desperately needs) and glitches the Character. mine_theblocks 23 — 2y
0
NVM!!! Thank you so much! I realized when I tried that I accidentally wrote a s! Thank you again! mine_theblocks 23 — 2y
Ad

Answer this question