So i don't know why but, this script breaks completely if the stringvalue (location = script.Parent.Direction) is changed. Basically, i made a script where it would see if the player is above the leading player in a race, and, it works but when the direction value is changed it just breaks and doesn't print , and just breaks the rest of the script.

I don't know why it's doing this but help would be appreciated.

script.Redstone.Changed:connect(function()
if game.Players:FindFirstChild(plr.Name).Character.Humanoid.Sit == false then return end
	
local chc = script.Parent.Parent.Parent.Players:FindFirstChild(plr.Name).Checkpoint
local chl = script.Parent.Parent.Parent.Players:FindFirstChild(plr.Name).Lap

print(chc.Value)

local xcurpos = tonumber(getpos())
local abopos = tostring(xcurpos - 1)
local curpos = tostring(xcurpos)

local x1 = poss:FindFirstChild(abopos)

if abopos == "0" then return end 
if chl.Value >= plrs:FindFirstChild(x1.Value).Checkpoint.Value and chc.Value >= plrs:FindFirstChild(x1.Value).Lap.Value then

local car1 = workspace:FindFirstChild("Car_"..plr.Name).DriveSeat
local car2 = workspace:FindFirstChild("Car_"..plrs:FindFirstChild(x1.Value).Name).DriveSeat

local ch2 = script.Parent.Parent.Parent.Players:FindFirstChild(plr.Name).Direction

print(script.Parent.Direction.Value) -- breaks here when direction value is changed

posupdate(chc,abopos,curpos,car1,car2)

end
end)