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

Character not teleporting to saved position?

Asked by
Fatul 9
4 years ago
Edited 4 years ago

I have a string value that takes my last known position and changes it with tostring(). When I join back, that value is exactly the same, showing that it saves correctly.

When I leave

p.CharacterRemoving:Connect(function(char)
    local lastPos = tostring(char.HumanoidRootPart.Position)
    StringModel.CharacterPosition.Value = lastPos
    print(StringModel.CharacterPosition.Value)
end)

When I join

p.CharacterAdded:Connect(function(char)
    if Spawned[p.Name].Spawned == false then --If first spawn
        local newPos = Vector3.new(tonumber(StringModel.CharacterPosition.Value))
        print(newPos) --last position is correct
        p.Character.HumanoidRootPart.CFrame = CFrame.new(newPos)
        --^ not working. i still spawn in the same old spot
        print("Teleported")
        Spawned[p.Name].Spawned = true
    end     
end)

I do not have a spawnlocation to conflict, not sure whats going on.

0
Try p.Character.HumanoidRootPart:MoveTo(newPos) Ziffixture 6913 — 4y
0
convert it back to s CFrame Value Donut792 216 — 4y
0
Neither worked. Fatul 9 — 4y
0
Can you clarify as to what / where the "stringmodel" is? if its in the player's character then when the character is removed so is the value... SerpentineKing 3885 — 4y
View all comments (2 more)
0
Its my data model for strings. It is not the problem, if you read what I said it saves when I leave and loads in the CORRECT position when i spawn back in. its just not moving towards it. Fatul 9 — 4y
0
when i join back: http://prntscr.com/ph18ao As you can see it grabbed my last position just fine. It just isn't teleporting to it. Fatul 9 — 4y

Answer this question