Please ONLY help with the Teleportation issue, any replies unrelated to this will be ignored
I have a check Point system that teleports you your check point, it does work but sometimes when you first join the game, the character not fully loaded yet and you don’t get teleported until you die, any solution?
local players = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local saveDataStore = dataStoreService:GetDataStore("DataStore")
CurrentCheckPoint = {}
function newCharacter(plr)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr
local CHECKPOINTS = Instance.new("IntValue")
CHECKPOINTS.Name = "CheckPoint"
CHECKPOINTS.Parent = stats
CHECKPOINTS.Value = 1
local data
local success, thecheckpoint = pcall(function()
data = saveDataStore:GetAsync(plr.UserId)
end)
if success then
CHECKPOINTS.Value = data
if CHECKPOINTS.Value == 0 then
CHECKPOINTS.Value = 1
end
end
--Teleports Players to their checkPoint
plr.CharacterAdded:connect(function(char)
if CHECKPOINTS.Value ~= nil then
local part = workspace.CheckPoints:WaitForChild(CHECKPOINTS.Value)
local PRIMPART = char:WaitForChild("HumanoidRootPart")
repeat wait(0.1) until PRIMPART ~= nil
print("Loaded")
PRIMPART.CFrame = part.CFrame + Vector3.new(0,1,0)
end
end)
end
players.PlayerAdded:connect(function(plr)
newCharacter(plr)
end)