game:GetService("Players").PlayerAdded:Connect(function(player)
addData(player) -- Gives the players Data
player.CharacterAdded:Connect(function(char)
repeat wait() until player.Character ~= nil -- Repeats until there is a players Character
print(player.leaderstats.Stage.Value) -- Check to see if this prints
Checkpoint.Check(player, char) -- Teleport to current stage // Module
local humanoid -- Empty Variable
repeat
humanoid = char:FindFirstChild("Humanoid")
wait()
until humanoid -- Repeats until there is a humanoid
humanoid.Died:Connect(function()
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1
Death.DeathAnimation(player)
end)
print(player.leaderstats.Stage.Value) -- Another Check
end)
end)
So What is meant to happen is When I spawn in My character should go to the current checkpoint which his Stage.value is but Instead doesn’t. This is the module script for the teleport:
Checkpoint.Check = function(player, character)
local Stage = player:WaitForChild('leaderstats').Stage
local Checkpoint = game.Workspace:WaitForChild("Checkpoints"):WaitForChild(Stage.Value)
wait(0.1)
character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(Checkpoint.Position + Vector3.new(0,5,0), Checkpoint.Position)
character:WaitForChild("HumanoidRootPart").Orientation = Vector3.new(0,0,0)
end