Arrow Checkpoint Obby Bug Fix

  1. What do you want to achieve? Arrow Checkpoint that lets players see an arrow every-time their is a new checkpoint ahead.

  2. What is the issue? I got everything to work so far, but later I had implemented a new “Reset Stages” Gui, and when I player clicks it. It resets the players stages, and respawns them at the beginning. Only problem is that after they use the “Reset Stage” Gui, they aren’t able to see the arrows so far.

  3. What solutions have you tried so far? Im guessing it has to do with this one part of the script, if anyone can help out.

Here’s the whole code - (Work’s totally fine just not after player reset’s stages)

--[[
	@author TwinPlayzDev_YT
	@since 6/1/2021
	This script will place arrows, on checkpoints for players to see where they are heading.
--]]

-- [ SERVICES ] --

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

-- [ LOCALS ] --

local arrow = ReplicatedStorage:WaitForChild'Arrow':Clone()
local sound = script.Parent:WaitForChild("Sound")
local player = Players.LocalPlayer

local stage = player:WaitForChild'leaderstats':WaitForChild'Stage'
local cps = workspace:WaitForChild'CheckPoints'

-- [ FUNCTIONS ] --

arrow.Parent = workspace

if(stage.Value+1<=15)then
	arrow.CFrame = cps:WaitForChild(stage.Value+1).CFrame*CFrame.new(0,arrow.Size.Y+0.5,0)*CFrame.Angles(0,0,math.rad(180))
end

coroutine.wrap(function()
	while wait() do
		if(arrow)then
			arrow.CFrame = arrow.CFrame*CFrame.Angles(0,math.rad(5),0)
		else
			break
		end
	end
end)()

stage:GetPropertyChangedSignal'Value':Connect(function()
	sound:Play()
	local newval = stage.Value
	if(arrow)then
		if(newval>1 and newval+1<=15)then
			arrow.CFrame = cps:WaitForChild(newval+1).CFrame*CFrame.new(0,arrow.Size.Y+0.5,0)*CFrame.Angles(0,0,math.rad(180))
		elseif(newval+1>15)then
			arrow:Destroy()
			script.Parent:Destroy()
		end
	end
end)

Im guessing it has to do with →

stage:GetPropertyChangedSignal'Value':Connect(function()
	sound:Play()
	local newval = stage.Value
	if(arrow)then
		if(newval>1 and newval+1<=15)then
			arrow.CFrame = cps:WaitForChild(newval+1).CFrame*CFrame.new(0,arrow.Size.Y+0.5,0)*CFrame.Angles(0,0,math.rad(180))
		elseif(newval+1>15)then
			arrow:Destroy()
			script.Parent:Destroy()
		end
	end
end)

Please let me know, how I can fix this.

1 Like

Why not make it so if the player clicks the reset stages button, the script repeats making the arrows visible again

2 Likes

What is the best way in achieving that?

I tried, making an OnClientEvent, but have no clue really what should go inside.

1 Like

Is this a localscript or a normal script?

1 Like

The whole script is “Local” and located inside StarterGui.

The script grabs a part from “Replicated”, and displays it at certain checkpoints.

All that needs fixed is, letting the script restart from checkpoint one. When the player resets their stages.

1 Like