Audio Timeposition Checkpoints are being completly ignored sometimes

Hey,

I have a massive script that completly worked before with the checkpoints.
Since i pushed my update with the script the checkpoints are being sometimes ignored. Just sometimes with some luck the checkpoints work.

OLD SCRIPT ISSUE:
The old script issue was that the time position run service thingy ran a checkpoint multiple times. With the new update of the script i added processedCheckpoints which checks if a checkpoint was already ran so it doesnt run multiple times.

My Script: (At the very bottom of the script there is the run function heartbeat thing)

local First = game.SoundService["1"]
local Second = game.SoundService["2"]
local Third = game.SoundService["3"]

local TweenService = game:GetService("TweenService")

local Jerky_Travis_Tracks_AC = game.Workspace.Jerky_Travis:FindFirstChild("AnimationController")
local Jerky_Travis_Tracks = {
	Track_01 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_01),
	Track_02 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_02),
	Track_03 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_03),
	Track_04 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_04)
}

local function Jerky_Travis_Glitch_CUE()
	local Jerky_Travis = game.Workspace["Jerky_Travis"] 
	local Jerky_Travis_Mesh = Jerky_Travis["M_MED_Cyclone_LOD0"] 
	local Jerky_Travis_Glitch = Jerky_Travis:WaitForChild("Glitch")

	Jerky_Travis_Mesh.Material = Enum.Material.ForceField
	task.wait(0.1)
	Jerky_Travis_Glitch.Parent = Jerky_Travis_Mesh

	task.wait(0.1)
	Jerky_Travis_Glitch.Parent = Jerky_Travis
	task.wait(0.1)
	Jerky_Travis_Mesh.Material = Enum.Material.Plastic
end

local function Jerky_Travis_MoveByGlitch_CUE(x, y, z)
	local currentCFrame = game.Workspace.Jerky_Travis.M_MED_Cyclone_LOD0.CFrame
	local newPosition = CFrame.new(x, y, z)
	local Jerky_Travis_Move = TweenService:Create(
		game.Workspace.Jerky_Travis.M_MED_Cyclone_LOD0,
		TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{CFrame = newPosition * currentCFrame.Rotation} 
	)
	Jerky_Travis_Move:Play()
end

game.ReplicatedStorage.EventRemotes.StartEvent.OnServerEvent:Connect(function(plr)
	if plr.UserId == 3933825740 then
		
		--First.TimePosition = 0.1
		--Second.TimePosition = 0.1
		--Third.TimePosition = 0.1
		
		First:Play()
		Second:Play()
		Third:Play()
	


		--game.SoundService["1"]:Play()
		--game.SoundService["2"]:Play()
		--game.SoundService["3"]:Play()

		local checkpoints = {
			[0.1] = function()	
				game.Workspace:WaitForChild("Jerky_Stage"):WaitForChild("Folder"):WaitForChild("Fog"):WaitForChild("ParticleEmitter").Enabled = true
				game.Workspace:WaitForChild("Jerky_Stage"):WaitForChild("Folder"):WaitForChild("Fog"):WaitForChild("ParticleEmitter").RGB.Enabled = true

				game.Workspace:WaitForChild("Astroworld").Main.Transparency = 0
				game.Workspace:WaitForChild("Astroworld").Main.sm_jerky_planet_speaker.Transparency = 0
				game.Workspace.Astroworld.Main.LocalTransparencyModifier = 0
				game.Workspace.Astroworld.Main.sm_jerky_planet_speaker.LocalTransparencyModifier = 0
				
				
				for _, descendant in ipairs(game.Workspace.Jerky_Stage.Folder:GetDescendants()) do
					if descendant.Name == "light" and descendant.Parent and descendant.Parent.Name == "light1" then
						descendant.Brightness = 10
						descendant.RGB.Enabled = true
					end
				end
				
				local LS_Astroworld_IN = TweenService:Create(
					game.Workspace.Astroworld.Main,
					TweenInfo.new(65, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{CFrame = CFrame.new(2975.237, 787.355, -3503.499)} 
				)
				LS_Astroworld_IN:Play()


			end,
			[21.5] = function()
				print(5)
				
				local Jerky_Screen = TweenService:Create(
					game.Workspace.Jerky_Stage.Folder.Jerky_Screen,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Transparency = 1}
				)
				local Jerky_ScreenBack = TweenService:Create(
					game.Workspace.Jerky_Stage.Folder.Jerky_ScreenBack,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Transparency = 1}
				)
				local T_Jerky_GlitchedCard = TweenService:Create(
					game.Workspace.Jerky_Stage.Folder.Jerky_Screen.T_Jerky_GlitchedCard,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Transparency = 1}
				)
				local T_Jerky_GroundLogo_Glow = TweenService:Create(
					game.Workspace.Jerky_Stage.GroundLogo.Texture,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Color3 = Color3.new(0.796078, 0.560784, 1)}
				)
				T_Jerky_GlitchedCard:Play()
				Jerky_Screen:Play()
				Jerky_ScreenBack:Play()
				T_Jerky_GroundLogo_Glow:Play()
			end,
			[58] = function()
				local ColorCorrectionFadeDark = TweenService:Create(
					game.Lighting.ColorCorrection,
					TweenInfo.new(6.5, Enum.EasingStyle.Quint, Enum.EasingDirection.In),
					{Brightness = -0.5}
				)
				local Jerky_Meteroid_IN = TweenService:Create(
					game.Workspace.Jerky_Metroid.Main,
					TweenInfo.new(6.5, Enum.EasingStyle.Quint, Enum.EasingDirection.In),
					{CFrame = CFrame.new(1679.462, 146.265, -3105.861)}
				)
				Jerky_Meteroid_IN:Play()
				ColorCorrectionFadeDark:Play()
				game.Workspace.Jerky_Metroid.Main.T_Jerky_Flare.Enabled = true
				game.Workspace.Jerky_Metroid.Main.T_Jerky_Dustsaa.Enabled = true
				game.Workspace.Jerky_Metroid.Main.T_Jerky_Stary.Enabled = true

			end,
			[63.5] = function()
				game.Lighting.ColorCorrection.Brightness = 0.7
				game.Lighting.Atmosphere.Color = Color3.new(1, 0.580392, 0.980392)
				game.Lighting.Atmosphere.Decay = Color3.new(0.32549, 0.254902, 0.360784)
				game.Lighting.Atmosphere.Haze = 2.35
				game.Lighting.Atmosphere.Density = 0.324
				
				
				local ColorCorrectionFadeNormal = TweenService:Create(
					game.Lighting.ColorCorrection,
					TweenInfo.new(2.5, Enum.EasingStyle.Quint, Enum.EasingDirection.In),
					{Brightness = 0.1}
				)
				ColorCorrectionFadeNormal:Play()
				
				game.Workspace.Jerky_Metroid.Main.T_Jerky_Flare.Enabled = false
				game.Workspace.Jerky_Metroid.Main.T_Jerky_Dustsaa.Enabled = false
				game.Workspace.Jerky_Metroid.Main.T_Jerky_Stary.Enabled = false
				game.Workspace.Jerky_Travis.M_MED_Cyclone_LOD0.Transparency = 0
				Jerky_Travis_Tracks.Track_01:Play()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_SpawnBump:FireAllClients()

				-- Launch all players into the air
				local Players = game:GetService("Players")
				for _, player in pairs(Players:GetPlayers()) do
					if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
						local humanoidRootPart = player.Character.HumanoidRootPart
						humanoidRootPart.Velocity = Vector3.new(0, 200, 0) -- Adjust the Y value for strength
					end
				end
			end,
			[67.7] = function()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				Jerky_Travis_Glitch_CUE()
			end,
			[68.4] = function()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				Jerky_Travis_Glitch_CUE()
			end,
			[69] = function()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				Jerky_Travis_Glitch_CUE()
			end,
			[69.6] = function()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				Jerky_Travis_Glitch_CUE()

			end,
			[70.3] = function()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				Jerky_Travis_Glitch_CUE()
			end,
			[75] = function()
				Jerky_Travis_Tracks.Track_02:Play()
				Jerky_Travis_Tracks.Track_01:Stop()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				
				Jerky_Travis_MoveByGlitch_CUE(1481.414, 255.19, -3224.329)
				Jerky_Travis_Glitch_CUE()
				
			end,
			[80] = function()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				Jerky_Travis_Glitch_CUE()
			end,
			[88] = function()
				Jerky_Travis_Tracks.Track_02:Stop()
				Jerky_Travis_Tracks.Track_03:Play()
				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				
				game.Workspace.StarsStageDirection.ParticleEmitter.Enabled = true
				
				Jerky_Travis_MoveByGlitch_CUE(1494.783, 255.19, -2745.898)
				Jerky_Travis_Glitch_CUE()				
			end,	
			[95.8] = function()
				Jerky_Travis_Tracks.Track_03:Stop()
				Jerky_Travis_Tracks.Track_04:Play()
				game.Workspace:WaitForChild("SlideDownCylinder").ForceField.CanCollide = true
				game.Workspace:WaitForChild("SlideDownCylinder").MaterialPart.CanCollide = true
				
				game.Workspace.StarsStageDirection.ParticleEmitter.Enabled = false

				
				local LS_SlideDownCylinder_Forcefield_IN = TweenService:Create(
					game.Workspace.SlideDownCylinder.ForceField,
					TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In),
					{Transparency = 0.8} 
				)
				local LS_SlideDownCylinder_MaterialPart_IN = TweenService:Create(
					game.Workspace.SlideDownCylinder.MaterialPart,
					TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In),
					{Transparency = 0.8} 
				)
				
				
				
				LS_SlideDownCylinder_Forcefield_IN:Play()
				LS_SlideDownCylinder_MaterialPart_IN:Play()

				game.ReplicatedStorage.EventRemotes.ShakeRemotes.Jerky_Bump:FireAllClients()
				Jerky_Travis_MoveByGlitch_CUE(1045.66, 254.68, -3047.876)
				Jerky_Travis_Glitch_CUE()		
			end,
			[100.5] = function()
				game.ReplicatedStorage.EventRemotes.FlashClientsEvent:FireAllClients()
			end,
			[101] = function()
				for i, v in pairs(game.Players:GetPlayers()) do
					print(v)

					local spawns = game.Workspace.SlideDownCylinder.Spawns:GetChildren()
					local spawnA = spawns[math.random(1, #spawns)]

					v.Character.HumanoidRootPart.CFrame = spawnA.CFrame
					v.Character.Humanoid.HipHeight = 0
					v.Character.Humanoid.WalkSpeed = 0
					v.Character.Humanoid.JumpPower = 0

					print(spawnA)

				end
			end,
			
			[110] = function()
				for i, v in pairs(game.Players:GetPlayers()) do

					game.Workspace:WaitForChild("SlideDownCylinder").ForceField.CanCollide = false
					game.Workspace:WaitForChild("SlideDownCylinder").MaterialPart.CanCollide = false
					game.Workspace:WaitForChild("SlideDownCylinder").ForceField.Transparency = 1
					game.Workspace:WaitForChild("SlideDownCylinder").MaterialPart.Transparency = 1



					v.Character.Humanoid.HipHeight = 2
					v.Character.Humanoid.WalkSpeed = 16
					v.Character.Humanoid.JumpPower = 50
					

				end
			end,
		}

		local processedCheckpoints = {}

		local connection
		connection = game:GetService("RunService").Heartbeat:Connect(function()
			for time, action in pairs(checkpoints) do
				if First.TimePosition >= time and not processedCheckpoints[time] then
					processedCheckpoints[time] = true 
					action() 
				end
			end

			if next(checkpoints) == nil or next(processedCheckpoints) == nil then
				connection:Disconnect()
			end
		end)

		
	end
end)

debugging:
1, Use the epsilon adjustment to handle timing skips.
2, make sure there’s no external modifications to First.TimePosition.

Errors:
1,Tweens and Timing Issues, Network delay may interfere with the sync between the audio.

2, Timing issues
if the sound’s TimePosition skips over a checkpoint value because of frame timing, First.TimePosition >= time may never become true for specific checkpoints.

You can try using this

local First = game.SoundService["1"]
local Second = game.SoundService["2"]
local Third = game.SoundService["3"]

local TweenService = game:GetService("TweenService")

local Jerky_Travis_Tracks_AC = game.Workspace.Jerky_Travis:FindFirstChild("AnimationController")
local Jerky_Travis_Tracks = {
	Track_01 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_01),
	Track_02 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_02),
	Track_03 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_03),
	Track_04 = Jerky_Travis_Tracks_AC:LoadAnimation(game.Workspace.Jerky_Travis.Anims.Track_04)
}

local function Jerky_Travis_Glitch_CUE()
	local Jerky_Travis = game.Workspace["Jerky_Travis"] 
	local Jerky_Travis_Mesh = Jerky_Travis["M_MED_Cyclone_LOD0"] 
	local Jerky_Travis_Glitch = Jerky_Travis:WaitForChild("Glitch")

	Jerky_Travis_Mesh.Material = Enum.Material.ForceField
	task.wait(0.1)
	Jerky_Travis_Glitch.Parent = Jerky_Travis_Mesh

	task.wait(0.1)
	Jerky_Travis_Glitch.Parent = Jerky_Travis
	task.wait(0.1)
	Jerky_Travis_Mesh.Material = Enum.Material.Plastic
end

local function Jerky_Travis_MoveByGlitch_CUE(x, y, z)
	local currentCFrame = game.Workspace.Jerky_Travis.M_MED_Cyclone_LOD0.CFrame
	local newPosition = CFrame.new(x, y, z)
	local Jerky_Travis_Move = TweenService:Create(
		game.Workspace.Jerky_Travis.M_MED_Cyclone_LOD0,
		TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{CFrame = newPosition * currentCFrame.Rotation} 
	)
	Jerky_Travis_Move:Play()
end

game.ReplicatedStorage.EventRemotes.StartEvent.OnServerEvent:Connect(function(plr)
	if plr.UserId == 3933825740 then
		First:Play()
		Second:Play()
		Third:Play()

		local checkpoints = {
			[0.1] = function()	
				game.Workspace:WaitForChild("Jerky_Stage"):WaitForChild("Folder"):WaitForChild("Fog"):WaitForChild("ParticleEmitter").Enabled = true
				game.Workspace:WaitForChild("Jerky_Stage"):WaitForChild("Folder"):WaitForChild("Fog"):WaitForChild("ParticleEmitter").RGB.Enabled = true

				game.Workspace:WaitForChild("Astroworld").Main.Transparency = 0
				game.Workspace:WaitForChild("Astroworld").Main.sm_jerky_planet_speaker.Transparency = 0
				game.Workspace.Astroworld.Main.LocalTransparencyModifier = 0
				game.Workspace.Astroworld.Main.sm_jerky_planet_speaker.LocalTransparencyModifier = 0
				
				for _, descendant in ipairs(game.Workspace.Jerky_Stage.Folder:GetDescendants()) do
					if descendant.Name == "light" and descendant.Parent and descendant.Parent.Name == "light1" then
						descendant.Brightness = 10
						descendant.RGB.Enabled = true
					end
				end
				
				local LS_Astroworld_IN = TweenService:Create(
					game.Workspace.Astroworld.Main,
					TweenInfo.new(65, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{CFrame = CFrame.new(2975.237, 787.355, -3503.499)} 
				)
				LS_Astroworld_IN:Play()
			end,
			[21.5] = function()
				print(5)
				local Jerky_Screen = TweenService:Create(
					game.Workspace.Jerky_Stage.Folder.Jerky_Screen,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Transparency = 1}
				)
				local Jerky_ScreenBack = TweenService:Create(
					game.Workspace.Jerky_Stage.Folder.Jerky_ScreenBack,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Transparency = 1}
				)
				local T_Jerky_GlitchedCard = TweenService:Create(
					game.Workspace.Jerky_Stage.Folder.Jerky_Screen.T_Jerky_GlitchedCard,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Transparency = 1}
				)
				local T_Jerky_GroundLogo_Glow = TweenService:Create(
					game.Workspace.Jerky_Stage.GroundLogo.Texture,
					TweenInfo.new(6, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
					{Color3 = Color3.new(0.796078, 0.560784, 1)}
				)
				T_Jerky_GlitchedCard:Play()
				Jerky_Screen:Play()
				Jerky_ScreenBack:Play()
				T_Jerky_GroundLogo_Glow:Play()
			end,
			-- Other checkpoints remain unchanged...
		}

		local processedCheckpoints = {}
		local connection

		connection = game:GetService("RunService").Heartbeat:Connect(function()
			local allProcessed = true
			for time, action in pairs(checkpoints) do
				if not processedCheckpoints[time] and math.abs(First.TimePosition - time) <= 0.05 then
					processedCheckpoints[time] = true
					action()
					print("Executed checkpoint:", time)
				end
				if not processedCheckpoints[time] then
					allProcessed = false
				end
			end

			if allProcessed then
				connection:Disconnect()
				print("Disconnected Heartbeat: All checkpoints processed.")
			end
		end)
	end
end)
1 Like