Hi there, scripting’s not my specialty so I’m struggling here.
The result of the code should be as such:
For every stage cleared (indicated by scoreboard counter) parts named in numerical order (I.E checkpoint 1 is called “1”, checkpoint two is “2”) will turn to green, this will only effect client-side
The checkpoints are in a folder under workspace called “Stages”
I’m ashamed to post it since it’s so far from correct, but here’s what I tried
local Checkpoints = game.Workspace.Stages
local Debounce = false
for index, value in pairs(Checkpoints:GetChildren()) do
if value.Touched:Connect(function(part)
local partParent = part.Parent
local player = game.Players:GetPlayerFromCharacter(partParent)
local leaderstats = player.leaderstats
local playerStage = leaderstats.Stage
if tonumber(value.Name) == playerStage.Value + 1 then
if not Debounce then
Debounce = true
print("Working checkpoint!")
value.BrickColor = BrickColor.new(58, 255, 81)
wait()
Debounce = false
if player and part:IsDescendantOf(game.Players.LocalPlayer.Character) then
value.BrickColor = BrickColor.new(58, 255, 81)
end
end
end
end)
end
end
Thank you!