I'm trying to make a script where it saves your position so you can rejoin in the same place. The only issue is, no matter what I do the script can't find the HumanoidRootPart. Script:
--aurqore was here
local datastore = game:GetService("DataStoreService")
local positionds = datastore:GetDataStore("Position")
game.Players.PlayerAdded:Connect(function(plr)
local playerds = positionds:GetAsync(plr.UserId)
local lastpos
if(playerds) then
plr.CharacterAdded:Connect(function(char)
wait(3)
char.HumanoidRootPart.Position = Vector3.new(playerds.x,playerds.y,playerds.z)
return
end)
end
plr.CharacterAdded:Connect(function(char)
while true do
wait(.1)
local humanoidrootpart = char.HumanoidRootPart
if humanoidrootpart then
print("found")
lastpos = {
x = humanoidrootpart.Position.X,
y = humanoidrootpart.Position.Y,
z = humanoidrootpart.Position.Z
}
end
end
end)
game.Players.PlayerRemoving:Connect(function(plr2)
if plr.UserId == plr.UserId then
positionds:SetAsync(plr.UserId,lastpos)
end
end)
end)
The output isn't printing "found" and when I leave it says that argument 2 is nil.

3 comments
try using :FindFirstChild() or :WaitForChild()
Didn't work.
What line does it say the error is on?