So I’m making a game with a friend, and for this simple obby checkpoint system, I seem to be stumped!
Here is my code:
-- made by recanman
for _, child in ipairs(script.Parent:GetChildren()) do
if (child:IsA("Folder")) then
for _, killpart in ipairs(child.Obby.KillParts:GetChildren()) do
if (killpart:IsA("Part")) then
killpart.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if (plr ~= nil) then
plr.Character.Humanoid.Health = 0
end
end)
end
end
end
end
for _, child in ipairs(script.Parent:GetChildren()) do
if (child:IsA("Folder")) then
child.Base.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if (plr ~= nil) then
local stage = plr.Character.CurrentStage.Value
if (tostring(stage + 1) == child.Name) then
stage = stage + 1
wait(1)
end
end
end)
end
end
This is not an obby game, thats why the stage is not a leaderstats.
My problem:
print(tostring(stage + 1) == child.Name) -- returns true
if (tostring(stage + 1) == child.Name) then -- doesn't run
I’ve tried tonumber and nothing at all, but nothing is working right now. This seems like an awfully simple fix, and I’m out of my mind. Any help would be appreciated, thanks for reading.