I need help with the uncuff state, it doesn't release but all other things it does

Alright, this is my issue. Always when I click the release button, it does everything except release.
The cuff is working, But the uncuff doesn’t. Please help me! It’s not the whole code, I just put the code where I need help.

Code:

		local target      = nil
		local playerTorso = nil
		
		target, TargetTorso = CheckForTargetTorso(part)
		playerTorso = CheckForTorso(player)
		if target then
			Using = true
			workspace[TargetTorso.Parent.Name].Humanoid.JumpPower = 0
			workspace[TargetTorso.Parent.Name].Humanoid.WalkSpeed = 0
			for i, tool in pairs(game.Players[TargetTorso.Parent.Name].Backpack:GetChildren()) do
				tool.Parent = game:GetService("ReplicatedStorage").Players[TargetTorso.Parent.Name].Tools
			end
			RemoteEvent:FireClient(player, 'Use')

			spawn(function()
				if Using then
					TargetTorso.Anchored = true		
					player.PlayerGui.ArrestGui.Enabled = true
				end				
				while Using == true and wait() do			
					TargetTorso.CFrame = playerTorso.CFrame * CFrame.new( 0, 0, -5 )
				end				
				
			end)			
			
		end
	
	elseif state == 'UnCuff' and Using == true then		
		TargetTorso.Anchored = false
		wait(0.5)
		Using = false
		print("Using set to false")
		workspace[TargetTorso.Parent.Name].Humanoid.JumpPower = 50
		workspace[TargetTorso.Parent.Name].Humanoid.WalkSpeed = 16
		print("Every humanoid property set to normal")
		player.PlayerGui.ArrestGui.Enabled = false
		print("ArrestGui Visibility set to false")
		for i, tool in pairs(game:GetService("ReplicatedStorage").Players[TargetTorso.Parent.Name].Tools:GetChildren()) do
			tool.Parent = game.Players[TargetTorso.Parent.Name].Backpack
		end
		print("Gave every tool.")
		
        print("Released.")
		wait()```

A lot of the code is missing so we can’t really help you. Are there any error messages in console? Where exactly does the script stop working as intended?

Hi, the script doesn’t stop, it prints everything. It has no errors,

local TargetTorso = nil
local Using = false


function CheckForTargetTorso(part)
	if part.Parent:IsA'Model' and part.Parent:FindFirstChildOfClass'Humanoid' then
		local char = part.Parent
		local torso
		if char:FindFirstChild('Torso') then
			torso = char.Torso
		elseif char:FindFirstChild('UpperTorso') then
			torso = char.UpperTorso
		end
		return char, torso
	end
end

	
	
function CheckForTorso(player)
	local Char = player.Character
	if Char:FindFirstChild'Torso' then
		return Char.Torso
	else 
		return Char.UpperTorso
	end
end

RemoteEvent.OnServerEvent:Connect(function(player, state, part)

What I’ve sent was the first code,
Now this is the last code.

		Using = false
		game.Players[TargetTorso.Parent.Name].Team = game.Teams["Jailed"]
		wait(0.1)
		game.Players[TargetTorso.Parent.Name]:LoadCharacter()
		wait(1)
		game.Players[TargetTorso.Parent.Name].PlayerGui.ArrestPrisonGui.Frame.Reason.Text = player.PlayerGui.ArrestGui.Frame.Reason.Reason.Value
		wait(0.5)
		game.Players[TargetTorso.Parent.Name].PlayerGui.ArrestPrisonGui.Enabled = true
		for i, tool in pairs(game.Players[TargetTorso.Parent.Name].Backpack:GetChildren()) do
			tool.Parent = game:GetService("ReplicatedStorage").Players[TargetTorso.Parent.Name].Tools
		end
		print("Arrested")
		
	end
	
end)```

Alright, but we also need to know what you mean by “all other things”. So we can understand what causes the problem.

Okay, I will tell you everything in detail. When I cuff the torso, it will cuff and the gui will appear. Everything normal till now. But when I press the release button, it won’t release, and the gui doesn’t go away from the first click. It goes away from random clicks. And the torso is still cuffed and the torso cannot move. The character doesn’t have the tools anymore, but it prints everything. It’s annoying.

Could you help me? I really need help with this.