Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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

Ad

Answer this question