Problem is with my new datastore script the position doesn't get set to the players position if they have never loaded before, wich ends in a 0,0,0 position wich ends in falling of the map... Here is the script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStore = game:GetService("DataStoreService")
local PositionSave = DataStore:GetDataStore("PlayerSave2")
local spawnPos = workspace:WaitForChild("SpawnPos")

game.Players.PlayerAdded:connect(function(player)
	
	local PlayerStats = player:WaitForChild("PlayerStats")
	local Pos = Instance.new("Vector3Value",player.PlayerStats)
	Pos.Name = "PlayerPosition"

	Pos.Value = PositionSave:GetAsync(player.UserId) or player.Character.HumanoidRootPart.Position	
	PositionSave:SetAsync(player.UserId, Pos.Value)
	
	Pos.Changed:connect(function()
  		PositionSave:SetAsync(player.UserId, player.Character.HumanoidRootPart.Position)
	end)
	
	game.Players.PlayerRemoving:connect(function(player)
 		PositionSave:SetAsync(player.UserId, player.PlayerStats.PlayerPosition.Value)
	end)	
	
end)

1 comment

0

Try pre-setting the position value to something if they've never loaded before?