I’m trying to make an obby game, and I’m watching a tutorial on how to make a " Saving Obby Checkpoints", but when I test it out, in the “Output” section it says " Checkpoints is not a valid member of Workspace “Workspace” - Server - CheckpointScript:7" I have tried taking away ) but it still does not work.
Code:
local dataStoreService = game:GetService("DataStoreService")
local stageStore = dataStoreService:GetDataStore("PlayerStageDataStore")
function plrToStage(plr)
repeat wait() until plr.Character.HumanoidRootPart
local stagePart = game.Workspace.Checkpoints:FindFirstChild(tostring(plr.leaderstats.Stage.Value))
plr.Character.HumanoidRootPart.CFrame = stagePart.CFrame + Vector3.new(0,2.5,0)
end
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Parent = leaderstats
local success, errorMsg = pcall(function()
stage.Value = stageStore:GetAsync(player.UserId)
end)
if success then
print("Successfully got "..player.Name.."'s stage data.")
else
warn(errorMsg)
end
if player.Character then
plrToStage(player)
end
player.CharacterAdded:Connect(function()
plrToStage(player)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMsg = pcall(function()
stageStore:SetAsync(player.UserId,player.leaderstats.Stage.Value)
end)
if success then
print("Successfully got "..player.Name.."'s stage data.")
else
warn(errorMsg)
end
end)
for _, cheackpoint in pairs(game.Workspace.Checkpoints:GetChildren()) do
cheackpoint.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local cheackpointNumber = tonumber(cheackpoint.Name)
if player.leaderstats.Stage.Value < cheackpointNumber then
player.leaderstats.Stage.Value = cheackpointNumber
end
end
end)
end
When he is scripting the part:
Plz tell me what I need to add or remove, because I don’t see where I went wrong.