Toggle switch script not working

Hi, I made a toggle switch script, and it doesn’t work for some reason.
I’m sure everything here is correct, but could you please overview and double-check?
Thanks so much

local switch = script.Parent
local dot = switch.Dot
local onposition = UDim2.new(0.5, 0, 0, 0)
local offposition = UDim2.new(0, 0, 0, 0)
local red = Color3.new(0.301961, 0.0235294, 0.0235294) --77,6,6
local green =  Color3.new(0, 0.666667, 0.498039) --0,170,127
local fdval = game.Players.LocalPlayer:WaitForChild("Settings"):WaitForChild("FastDialogue")
local FastDialogue = false

local function updateSettings()
	fdval.Value = FastDialogue
	wait()
	game.ReplicatedStorage.OtherStatus.UpdateSettings:FireServer("FastDialogue", FastDialogue)
end

local function turnOn()
	dot:TweenPosition(onposition)
	switch.Corners.ImageColor3 = green
	switch.On.Value = true
	FastDialogue = true
	wait()
	updateSettings()	
end
local function turnOff()
	dot:TweenPosition(offposition)
	switch.Corners.ImageColor3 = red
	switch.On.Value = false
	FastDialogue = false
	wait()
	updateSettings()
end

local function turnOnManually()
	dot.Position = onposition
	switch.Corners.ImageColor3 = green
	switch.On.Value = true
	FastDialogue = true
end

local function turnOffManually()
	dot.Position = onposition
	switch.Corners.ImageColor3 = red
	switch.On.Value = false
	FastDialogue = false
end

if dot.Position == onposition and fdval == false then
	turnOffManually()
elseif dot.Position == offposition and fdval == true then
	turnOnManually()
end

switch.MouseButton1Down:Connect(function()
	if dot.Position == onposition and fdval == true then
		turnOff() 
	elseif dot.Position == offposition and fdval == false then
		turnOn()
	end
end)

dot.MouseButton1Down:Connect(function()
	if dot.Position == onposition and fdval == true then
		turnOff() 
	elseif dot.Position == offposition and fdval == false then
		turnOn()
	end
end)

while true do
	wait()
	FastDialogue = fdval.Value
	wait()
	print(FastDialogue)
end

Nvm, I legit solved it right after making this post.
Turns out I was using fdval as a statement, not as a value.
The working script would go as follows:

local switch = script.Parent
local dot = switch.Dot
local onposition = UDim2.new(0.5, 0, 0, 0)
local offposition = UDim2.new(0, 0, 0, 0)
local red = Color3.new(0.301961, 0.0235294, 0.0235294) --77,6,6
local green =  Color3.new(0, 0.666667, 0.498039) --0,170,127
local fdval = game.Players.LocalPlayer:WaitForChild("Settings"):WaitForChild("FastDialogue")
local FastDialogue = false

local function updateSettings()
	fdval.Value = FastDialogue
	wait()
	game.ReplicatedStorage.OtherStatus.UpdateSettings:FireServer("FastDialogue", FastDialogue)
end

local function turnOn()
	dot:TweenPosition(onposition)
	switch.Corners.ImageColor3 = green
	switch.On.Value = true
	FastDialogue = true
	wait()
	updateSettings()	
end
local function turnOff()
	dot:TweenPosition(offposition)
	switch.Corners.ImageColor3 = red
	switch.On.Value = false
	FastDialogue = false
	wait()
	updateSettings()
end

local function turnOnManually()
	dot.Position = onposition
	switch.Corners.ImageColor3 = green
	switch.On.Value = true
	FastDialogue = true
end

local function turnOffManually()
	dot.Position = onposition
	switch.Corners.ImageColor3 = red
	switch.On.Value = false
	FastDialogue = false
end

if dot.Position == onposition and fdval.Value == false then
	turnOffManually()
elseif dot.Position == offposition and fdval.Value == true then
	turnOnManually()
end

switch.MouseButton1Down:Connect(function()
	if dot.Position == onposition and fdval.Value == true then
		turnOff() 
	elseif dot.Position == offposition and fdval.Value == false then
		turnOn()
	end
end)

dot.MouseButton1Down:Connect(function()
	if dot.Position == onposition and fdval.Value == true then
		turnOff() 
	elseif dot.Position == offposition and fdval.Value == false then
		turnOn()
	end
end)

while true do
	wait()
	FastDialogue = fdval.Value
end