I am working on a checkpoint system and I don’t know how to check all the checkpoints and when they touch the checkpoint, no matter which check point it is, it will change color! Heres the code `local Checkpoints = game.Workspace.Checkpoints
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new(“Folder”, plr)
leaderstats.Name = “leaderstats”
local Checkpoint = Instance.new(“IntValue”, leaderstats)
Checkpoint.Name = “Stage”
Checkpoint.Value = 1
plr.CharacterAdded:Connect(function(char)
wait()
if Checkpoint.Value > 1 then
char:MoveTo(Checkpoints:FindFirstChild(Checkpoint.Value - 1).Position)
end
end)
end)
for i, v in pairs(Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local Checkpoint = plr.leaderstats.Stage
if tonumber(v.Name) == Checkpoint.Value then
Checkpoint.Value += 1
end
end
end)
end end
Theirs a folder called Checkpoints and it has 1,2,3,etc
I want it to change color but the problem is I only know how to do it one checkpoint at a time and instead have the script check which checkpoint is which and that checkpoint turns green etc
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new(“Folder”, plr)
leaderstats.Name = “leaderstats”
local Checkpoint = Instance.new(“IntValue”, leaderstats)
Checkpoint.Name = “Stage”
Checkpoint.Value = 1
plr.CharacterAdded:Connect(function(char)
wait()
if Checkpoint.Value > 1 then
char:MoveTo(Checkpoints:FindFirstChild(Checkpoint.Value - 1).Position)
end
end)
end)
for i, v in pairs(Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local Checkpoint = plr.leaderstats.Stage
if tonumber(v.Name) == Checkpoint.Value then
Checkpoint.Value += 1
end
end
end)
end end
(I am confused as to why there are 2 extra end at the end)
IDK how to do that lol I never really work with remote events and I want that to happen but I don’t know what to use for it. Like I did :GetChildren() is there something that is related to It that checks if all past checkpoints are green and when you claim on its green?