Ok so basically I'm making an obby and I have a script that makes the checkpoints change color once they are touched. To expand on this, I'm trying to make a script that checks the player's stage value and if the stage value is higher than the value of a checkpoint, then the color of the checkpoints up to that stage will already be that color. This is written in a local script. I'm extremely new to scripting and I'm sure tons of things in this script are wrong but I really would like some feedback. I would also like to add that I plan on making it so that you can reset your stage and when that happens, I need the checkpoints to return to the original color, so I would like for any solution to be compatible with that as well. Thank you.
local stageHolder = game.Workspace.Stages
local stages = stageHolder:GetChildren()
local blue = table.getn(stages)
local player = script.Parent.Parent
local stageValue = player.leaderstats.Stage.Value
for i,v in pairs(stages) do
local text = i
local number = v
while true do
if v >= stageValue then stageHolder[v].Color = Color3.fromRGB(71, 255, 243)
wait(0.1)
end
end
end

1 comment
I already have a script to change the color when they're touched, I just need to check what stage the player is on when they join and make all the checkpoints behind them blue already.