Script still works even when bool value is set to false

im setting a bool value to false whenever my round system is in intermission

local player = game.Players.LocalPlayer

local UIS = game:GetService("UserInputService")

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Custom

repeat wait()
	camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.Lobby.LobbyCamera.CFrame

local GameMap = workspace.Map.CurrentMap

local function Play()
		
	workspace.Values.CanPlay.Changed:Connect(function(newValue)
		print(newValue)

		if newValue == true then
			script.Parent.Activated:Connect(function()

				game:GetService("ReplicatedStorage").Remotes.AddCharacterEvent:FireServer()

				camera.CameraType = Enum.CameraType.Custom
				script.Parent.Visible = false
				script.Parent.Parent.Character.Visible = false
				script.Parent.Parent.Stats.Visible = false
				script.Parent.Parent.LoadoutButton.Visible = false
				script.Parent.Parent.CustomizeButton.Visible = false
				script.Parent.Parent.Code.Visible = false
				script.Parent.Parent.PremiumButton.Visible = false
				script.Parent.Parent.StoreButton.Visible = false
				script.Parent.Parent.Map.Visible = false
				script.Parent.Parent.Yen.Visible = false
				script.Parent.Parent.Bloodfruit.Visible = false
				script.Parent.Parent.Parent.Level.LevelBar.Visible = true
				script.Parent.Parent.Parent.Level.LevelStats.Visible = true
				game.Lighting.Blur.Size = 1

				player.Character:WaitForChild("HumanoidRootPart").Anchored = false
			end)
		end
	end)
end

script.Parent.Activated:Connect(function()
	Play()
end)

UIS.InputBegan:Connect(function(Input, Processed)
	if Input.KeyCode == Enum.KeyCode.Space and not Processed then 
			Play()
	end
end)

however even when the bool value is set to false this is still running and idk why, it works perfectly fine for the very first round and then once its set to false again this will still be doing whats inside the function.

bool values cannot be changed on local to server you would have to use remote events.

im changing the value in a server script tho? ill try a remote event

Your script does not have a method to stop the currently running game, it only has a method to run it.

local function Play()
	...
	...
		if newValue == true then
			script.Parent.Activated:Once(function() -- Runs once, unlike :Connect()

				game:GetService("ReplicatedStorage").Remotes.AddCharacterEvent:FireServer()

				camera.CameraType = Enum.CameraType.Custom
				script.Parent.Visible = false
				script.Parent.Parent.Character.Visible = false
				script.Parent.Parent.Stats.Visible = false
				script.Parent.Parent.LoadoutButton.Visible = false
				script.Parent.Parent.CustomizeButton.Visible = false
				script.Parent.Parent.Code.Visible = false
				script.Parent.Parent.PremiumButton.Visible = false
				script.Parent.Parent.StoreButton.Visible = false
				script.Parent.Parent.Map.Visible = false
				script.Parent.Parent.Yen.Visible = false
				script.Parent.Parent.Bloodfruit.Visible = false
				script.Parent.Parent.Parent.Level.LevelBar.Visible = true
				script.Parent.Parent.Parent.Level.LevelStats.Visible = true
				game.Lighting.Blur.Size = 1

				player.Character:WaitForChild("HumanoidRootPart").Anchored = false
			end)
		else
			-- Resets all settings here. I don't know
			-- how you would set this up, but you
			-- can simply copy the previous code
			-- for running a game, and reverse the
			-- values.
			
			-- If you have other code that runs
			-- once the game starts, they should
			-- also take notice of the BoolValue
			-- being set to false, and then they
			-- can also shut down with the main
			-- script.
		end
	...
	...