for _, object in pairs(checkpoints:GetChildren()) do
local num = object.Name
local stage = tonumber(object.Name)
local hitbox = object.HitBox
local label = object.Number.SurfaceGui.TextLabel
label.Text = "Stage " .. num
hitbox.Touched:connect(function(hit)
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
local player = humanoid.Parent.Name
local plr = game:GetService("Players"):FindFirstChild(player)
print("Hit Player Name, " .. player)
-- Find player's folder position.
local success, folderName = getPlrFolder(player)
local confirmation = false
if success then
local folder = sss:FindFirstChild(folderName)
local a = tostring(folder.Stages.Value)
print("text " .. a)
local previousStage = folder.Stages.Value
local difference = stage - previousStage
if difference < 2 or previousStage == 0 then
folder.Stages.Value = stage
print(player .. " stage set to " .. tostring(folder.Stages.Value))
confirmation = true -- Unlocked Stage Confirmed
else
plr:Kick(prefix .. "Skipped a Stage. Stage Confirmation failed.")
end
end
if confirmation then
print(prefix .. player .. " reached Stage " .. num)
else
print(prefix .. "Stage Confirmation for " .. player .. " at stage " .. num .. " failed.")
end
end
end)
--object.Touched:connect(function(hit)
end
Above is my code block ^^^^
Here is where the error is happening: local previousStage = folder.Stages.Value.
I even added a print statement before it, but its not printing at all�
Thereās something in your conditional statement thatās setting the value of Stages to nil (which is causing an error because nil is not a numerical value)
if difference < 2 or previousStage == 0 then
folder.Stages.Value = stage
Can you try adding print(stage) and see what it outputs?
if success then
print(stage)
local folder = sss:FindFirstChild(folderName)
local a = tostring(folder.Stages.Value)
print("text " .. a)
local previousStage = folder.Stages.Value
local difference = stage - previousStage
I added a print(stage) there and it outputs ā1ā.
(Also its still not printing this print statement before the error, which is weird.)
Attempted to index ānilā means that it couldnāt find a object named stages or an object with the property(or a child) called Value this could be a couple things
local success, folderName = getPlrFolder(player)
Maybe this isnāt returning a foldername*
You donāt seem to have a Debounce so this might be whats wrong
if difference < 2 or previousStage == 0 then
folder.Stages.Value = stage
You code will run for each part that touches it so basically if UpperArm touches it, it will run.
if LowerTorso Touches it, it will run etc etc
Edit: Attempt to index ānilā should also come with what you tried to index it with so the error should say something like this
Attempt to index ānilā with Value
or
Attempt to index ānilā with āStagesā
Ah thanks, I tried to check what path it was aiming for and it was trying to find the folder directly in SSS rather than inside its location of PlayerInformation.
local folder = sss:FindFirstChild(folderName)
this was the root of the error ^ Thanks for the help