Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I have a great question im trying to build a parkour map and I cant figure this out?

local DataService = game:GetService("DataStoreService") local DataStore = DataService:GetDataStore("data1")

local cpFolder = game.Workspace:WaitForChild("Level")

game.Players.PlayerAdded:Connect(function(player) local key = "player-" .. player.UserId

local GetSave = DataStore:GetAsync(key)

local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"

local checkpoint = Instance.new("IntValue", leaderstats)
checkpoint.Name = "Level"

if GetSave then
	checkpoint.Value = GetSave
	print("Data Loaded For " .. player.Name)
else
	checkpoint.Value = 1
	print("New Data Created For " .. player.Name)
end

player.CharacterAdded:Connect(function(character)
	repeat wait() until workspace:FindFirstChild(character.Name)

	local player = game.Players:GetPlayerFromCharacter(character)
	local checkpoint = cpFolder[player.leaderstats.Level.Value]

	character.HumanoidRootPart.CFrame = checkpoint.CFrame + Vector3.new(0,2,0)
end)

end)

game.Players.PlayerRemoving:Connect(function(player) local key = "player-" .. player.UserId

DataStore:SetAsync(key, player.leaderstats.Level.Value)

print("Data Successfully Saved For " .. player.Name)

end)

The problem is WaitForChild("Level") is there anything you guys can help me

1 answer

✓ Accepted answer

Level isn't a member of workspace, it's a leaderstat

This discussion is preserved as it was. New answers, comments, and votes are closed.