I want to make a part ( Obby checkpoint ) When touch, turn green in color and stay the same way even when the players rejoin. I made a Local Script and put it in the obby checkpoint but it does not work.
while true do
if game.Players.LocalPlayer.leaderstats.Stage.Value > 0 then
script.Parent.BrickColor = BrickColor.new("Lime green")
wait()
end
end
repeat wait() until game.Players.LocalPlayer.leaderstats.Stage
if game.Players.LocalPlayer.leaderstats.Stage.Value > 0 then
workspace:FindFirstChild("1").BrickColor = BrickColor.new("Lime Green")
end
Also this is not the best way to do whatever you want i recommend making Checkpoints folder adding your checkpoints in them and doing for i,v in pairs(CheckpointsFolder:GetChildren()) do
local stage = 16 --Replace 16 by the stage of the checkpoint.
local playerStage = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Stage")
local function ChangeCheckpointColor()
if playerStage.Value >= stage then
script.Parent.BrickColor = BrickColor.new("Lime green")
end
end
ChangeCheckpointColor()
playerStage.Changed:Connect(ChangeCheckpointColor())
local checkpoint = <instance value> --Replace <instance value> by the checkpoint instance.
local stage = <number value> --Replace <number value> by the stage of the checkpoint.
local playerStage = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Stage")
local function ChangeCheckpointColor()
if playerStage.Value >= stage then
checkpoint.BrickColor = BrickColor.new("Lime green")
end
end
ChangeCheckpointColor()
playerStage.Changed:Connect(ChangeCheckpointColor())
This must be a local script which must be in StarterCharacterScripts.
“checkpoint” variable must be an instance value. By example, if the parent of the checkpoint is the Workspace and the name of your checkpoint is “Checkpoint”, the value of “checkpoint” variable must be game.Workspace.Checkpoint. Things like “game.Workspace.Checkpoint” are Instance values.