Hello, good afternoon, look, I have this script that what it does is save the assigned positions and load them. MoveTo does not work for me, it does not give me any errors and prints the locations, thanks I hope to solve it with your help.
local DataStore = game:GetService("DataStoreService")
local DataStore1 = DataStore:GetDataStore("position1")
local DataStore2 = DataStore:GetDataStore("position2")
local DataStore3 = DataStore:GetDataStore("position3")
local vectorCharcter1 = Vector3.new(-82.51, 45.688, 9.173)
local vectorCharcter2 = Vector3.new(25.83, 165.688, -124.377)
local vectorCharcter3 = Vector3.new(120.05, 147.957, 16.253)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local VectorToTable1 = function(vec)
return {vec.X,vec.Y,vec.Z}
end
local VectorToTable2 = function(vec)
return {vec.X,vec.Y,vec.Z}
end
local VectorToTable3 = function(vec)
return {vec.X,vec.Y,vec.Z}
end
local TableToVector1 = function(tab, vec)
return Vector3.new(tab[1],tab[2],tab[3])
end
local TableToVector2 = function(tab, vec)
return Vector3.new(tab[1],tab[2],tab[3])
end
local TableToVector3 = function(tab, vec)
return Vector3.new(tab[1],tab[2],tab[3])
end
local dataGet1 = DataStore1:GetAsync('position1')
local dataGet2 = DataStore2:GetAsync('position2')
local dataGet3 = DataStore3:GetAsync('position3')
local RamdomPosition = math.random(1,3)
if RamdomPosition == 1 then
TableToVector1(dataGet1, vectorCharcter1)
character:SetPrimaryPartCFrame(game.Workspace.Ground.CFrame + vectorCharcter1)
print(TableToVector1(dataGet1, vectorCharcter1))
print(VectorToTable1(vectorCharcter1))
elseif RamdomPosition == 2 then
TableToVector2(dataGet2, vectorCharcter2)
character:SetPrimaryPartCFrame(game.Workspace.Ground.CFrame + vectorCharcter2)
print(TableToVector2(dataGet2, vectorCharcter2))
print(VectorToTable1(vectorCharcter2))
elseif RamdomPosition == 3 then
TableToVector3(dataGet3, vectorCharcter3)
character:SetPrimaryPartCFrame(game.Workspace.Ground.CFrame + vectorCharcter3)
print(TableToVector3(dataGet3, vectorCharcter3))
print(VectorToTable1(vectorCharcter3))
end
character:WaitForChild("Humanoid").Died:Connect(function()
local dataSet1 = DataStore1:SetAsync('position1',VectorToTable1(vectorCharcter1))
local dataSet2 = DataStore2:SetAsync('position2',VectorToTable2(vectorCharcter2))
local dataSet3 = DataStore3:SetAsync('position3',VectorToTable3(vectorCharcter3))
end)
end)
end)

2 comments
I work concatenating CFrame to BasePlate and adding the Vector3 of the location that I have assigned but it goes very far does not put in that assigned location. That works me half.
had the BasePlate off center was not in point 0