I am trying to set the players CFrame to a parts cframe in a folder every time they respawn;
player.CharacterAdded:Connect(function(char)
if player.leaderstats.Stage.Value ~= 0 then
local spawnPart = workspace.Checkpoints:FindFirstChild(player.leaderstats.Stage.Name)
char.HumanoidRootPart.CFrame = spawnPart.CFrame + Vector3.new(0,1,0)
end
Yea so I made an error but I fixed but it still wont bring me to the part:
player.CharacterAdded:Connect(function(char)
if player.leaderstats.Stage.Value ~= 0 then
local spawnPart = workspace.Checkpoints:FindFirstChild(player.leaderstats.Stage.Value)
char.HumanoidRootPart.CFrame = spawnPart.CFrame + Vector3.new(0,1,0)
end
I believe the issue is the way you are getting the spawnPart. You are reading the name of the leaderstats Stage object which returns Stage, however, you probably want to use Value.
Try replacing
local spawnPart = workspace.Checkpoints:FindFirstChild(player.leaderstats.Stage.Name)
with
local spawnPart = workspace.Checkpoints:FindFirstChild(player.leaderstats.Stage.Value)