I need help with obby checkpoint script

Firstly, I already made my obby checkpoint which works well but the one thing that bothers me is when you reset your character the UI checkpoint reappears even after claiming it. Here’s an example of when I claim the checkpoint :


Here’s an example of when I reset after claiming the checkpoint :

I don’t want this to reappear when I reset as I’ve already claimed the checkpoint.

For my checkpoints, I have 2 scripts. A local script which is located in the StarterGui and a script which is located in the ServerScriptService. The local script creates the effect, like the UI, particles, and the neon light effect. The script keeps account of what stage you are in and teleports you to that stage when you die.

Script:

local Checkpoints = workspace.Checkpoints
local stages = 1


game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(chr)
		wait()
		chr.HumanoidRootPart.CFrame = Checkpoints[stages].CFrame
		
		for i, stage in pairs(Checkpoints:GetChildren()) do
			stage.Touched:Connect(function(Hit)
				if Hit.parent == chr then
					if tonumber(stage.Name) > stages then
						stages = tonumber(stage.Name)
					end
				end
			end)
		end
	end)
end)

Local Script:

local player = game.Players.LocalPlayer
local character = player.Character

local checkSound = game.ReplicatedStorage.Checkpoint_Shadow
local effect = game.ReplicatedStorage.ParticleEmitter:Clone()

local plyrGui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')
local UI = plyrGui:WaitForChild("CheckpointDisplay")

local debounce = true

local Checkpoints = workspace.Checkpoints
local stages = 1

for i, stage in pairs(Checkpoints:GetChildren()) do
	stage.Touched:Connect(function(Hit)
		if Hit.parent == character then
			if tonumber(stage.Name) > stages then
				stages = tonumber(stage.Name)
				print(stages)
				stage.Material = Enum.Material.Neon
				effect.Parent = stage
				checkSound:Play()
				UI.Enabled = true
				checkSound.Ended:Wait()
				UI.Enabled = false
				stage.Material = Enum.Material.SmoothPlastic
				effect:Remove()
			end
		end
	end)
end

I’ve realized that my local script resets the stages every time I reset my character, I’ve tried ways to work around it like creating an IntValue that stores your stages in a ReplicatedStorage or a remote event that would add your stages but they all lead to the same results.

Can someone help me find an answer, I would much appreciate it :slight_smile:

SOLUTION :
The solution was to have bool values inserted in each checkpoint, and when you step on the checkpoints the bool value changes.

3 Likes

Just set the ResetOnSpawn property to false after the gui is shown, thus we know they have reached the checkpoint.

2 Likes

I’ve tried that but it didn’t work because the local script counts the stages as well but it also resets when you reset, meaning that the stage value is back to one and therefore my local script would create the effect as It thinks that I have jumped from stage 1 to stage 3.

2 Likes

What do you mean by this? Your local script shouldn’t reset if that property is false. Do you want your local script to know if a player has died, returning them to their previous checkpoint or their checkpoint they currently are on?

2 Likes

I’m not sure if my local script resets but one of my variable values called stages comes back to 1 when I do reset my character. I wanted my local script to keep count of the stages the player is in and to create effects when the checkpoint they touch is a higher stage number than their previous.

1 Like

You can use the boolvalue, and check if it level something passed.(im sorry if my grammar terrible lol)

1 Like

Where is your localscript exactly?

1 Like

My local script is in the StarterGUI
localscript check

Can you move that inside the GUI that you set ResetOnSpawn to false?

1 Like

Perhaps that might work, idk lol

Btw, do you mean visible over enabled?

1 Like

enabled, btw it’s fixed. Thanks to all your help guys XD

1 Like

No problem at all (i just need characters for the post)