I am making an obby checkpoint system with saves and am running into the following issue
Stage is not a valid member of Folder
here are my code snippets: script in checkpoint part
if humanoid then
print(plr.Parent.Name)
local player1 = game:GetService("Players"):GetPlayerFromCharacter(workspace[plr.Parent.Name])
print(type(player1))
local spawns = datastoreservice:GetDataStore("spawns")
print(player1.userId)
spawns:SetAsync(player1.userId, encodeCFrame(player1.Character:WaitForChild("HumanoidRootPart").CFrame))
-- printTable(player1.leaderstats:GetChildren())
game:GetService("Players")[player1.Name].leaderstats["Stage"] = script.Parent.Name
end
end)
script in serverscriptservice
game:GetService('Players').PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local level = Instance.new("IntValue", leaderstats)
level.Name = "Stage"
level.Value = 1
print(player.leaderstats.Stage)
Please could someone help as to why this error is being caused as i can see the playername.leaderstats.Stage value in explorer but in the script it cant find it any help would be appreciated Josh Edit: fix code edit 2: only include references to leaderstats

5 comments
http://idownvotedbecau.se/toomuchcode Please don't make us pick through your code line by line to find the issue, post only and ONLY a minimal, complete, and verifiable example. That is, post as little code as you can that can still reproduce the problem, but make sure it's complete, and verifiable being, it would still compile and run, and produce the problem. I will happily remove -1 if you fix
sorry its because i dont know whats causing it so i cant identify the bits and im new to lua
oki fixed it
Now you have too little. In the first one, there is no humanoid variable. So we don't know the background context. In the second one, you're missing an end for your function literal and a closing ) to close off that :Connect() call. Make sure the code you provide at least compiles.
https://stackoverflow.com/help/minimal-reproducible-example Here is how to create an MCVE.