Issue with road system files

i’m having an error with my version of a moving road that changes speed
im making my game called Kamote Rider which is like similar to mobile game called traffic rider where you do close call stuff something like that

the tunnel road value won’t change so idk how to make a different types of road when they’ve passed on the current road.

my english might be bad sometimes but thank you for understanding me and your help.

--wait(3)
ValueHandler = game:GetService("ReplicatedStorage").Events.ValueChangeHandler
speed = game:GetService("ReplicatedStorage"):FindFirstChild("ValueFolder").SpeedValue

local chances = game:GetService("ReplicatedStorage").ValueFolder.ChancesOfTunnel
recentpos = script.Parent.CFrame

local TunnelMode = game:GetService("ReplicatedStorage").ValueFolder.TunnelMode
local TunnelLimit = game:GetService("ReplicatedStorage").ValueFolder.TunnelLimit

local Tunnel = game:GetService("ReplicatedStorage").RoadFolder.KamoteRoads
local MainRoad = game:GetService("ReplicatedStorage").RoadFolder.KamoteRoads


function Swait(Number)
	if Number == nil or Number == 0 then
		game:GetService("RunService").RenderStepped:Wait()
	else
		for i = 1,Number do
			game:GetService("RunService").RenderStepped:Wait()
		end
	end
end

while true do
	ValueHandler:FireServer("NotValue=Value",chances,math.random(1,4))
	if chances == 1 then
		ValueHandler:FireServer("NotValue=Value",TunnelMode,true)
		print(chances.Value)
		print(TunnelMode.Value)
	end
	if speed.Value == 1 then
		
		for i = 1,455 do
			Swait()
			script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame*CFrame.new(0,0,60),0.02)
		end
		wait()
		if TunnelMode ~= true then
			--chances = math.random(1,50)
			local a = MainRoad:Clone()
			a.Parent = workspace
			a.TrueBaseplate.Script.Enabled = true
			if chances == 1 then
				ValueHandler:FireServer("NotValue=Value",TunnelMode,true)
			end
		else
			local a = Tunnel:Clone()
			a.Parent = workspace
			a.TrueBaseplate.Script.Enabled = true
			ValueHandler:FireServer("Value=Value",TunnelLimit,-1)
			if TunnelLimit == 0 then
				ValueHandler:FireServer("NotValue=Value",TunnelMode,false)
				ValueHandler:FireServer("NotValue=Value",TunnelLimit,5)
			end
		end
		for i = 1,450 do
			Swait()
			script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame*CFrame.new(0,0,60),0.02)
		end
		script.Parent.Parent:Destroy()
		script:Destroy()
		break
		--wait()
		--script.Parent.CFrame = recentpos
		
	elseif speed.Value == 3 then
		
		for i = 1,215 do
			Swait()
			script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame*CFrame.new(0,0,60),0.05)
		end
		wait()
		if TunnelMode ~= true then
			--chances = math.random(1,50)
			print(chances.Value)
			print(TunnelMode.Value)
			local a = MainRoad:Clone()
			a.Parent = workspace
			a.TrueBaseplate.Script.Enabled = true
			if chances == 1 then
				ValueHandler:FireServer("NotValue=Value",TunnelMode,true)
			end
		else
			local a = Tunnel:Clone()
			a.Parent = workspace
			a.TrueBaseplate.Script.Enabled = true
			ValueHandler:FireServer("Value=Value",TunnelLimit,-1)
			if TunnelLimit == 0 then
				ValueHandler:FireServer("NotValue=Value",TunnelMode,false)
				ValueHandler:FireServer(TunnelLimit,5)
			end
		end
		for i = 1,250 do
			Swait()
			script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame*CFrame.new(0,0,60),0.05)
		end
		script.Parent.Parent:Destroy()
		script:Destroy()
		break
		--wait()
		--script.Parent.CFrame = recentpos
		
		
	elseif speed.Value == 5 then

		for i = 1,125 do
			Swait()
			script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame*CFrame.new(0,0,60),0.07)
		end
		wait()
		if TunnelMode ~= true then
			--chances = math.random(1,50)
			print(chances.Value)
			print(TunnelMode.Value)
			local a = MainRoad:Clone()
			a.Parent = workspace
			a.TrueBaseplate.Script.Enabled = true
			if chances == 1 then
				ValueHandler:FireServer("NotValue=Value",TunnelMode,true)
			end
		else
			local a = Tunnel:Clone()
			a.Parent = workspace
			a.TrueBaseplate.Script.Enabled = true
			ValueHandler:FireServer("Value=Value",TunnelLimit,-1)
			if TunnelLimit == 0 then
				ValueHandler:FireServer("NotValue=Value",TunnelMode,false)
				ValueHandler:FireServer(TunnelLimit,5)
			end
		end
		for i = 1,120 do
			Swait()
			script.Parent.CFrame = script.Parent.CFrame:Lerp(script.Parent.CFrame*CFrame.new(0,0,60),0.07)
		end
		script.Parent.Parent:Destroy()
		script:Destroy()
		break
		--wait()
		--script.Parent.CFrame = recentpos
		
	else
		error("Invalid Number or Kind of Number don't exist!")
	end
end

by the way all of my road scripts are client sided
Road Model ← File Link will expire for 4/28/2024