i am trying to make a surfacegui that shows the amount of players there are in a room, i created a tranparent part that covers the whole indoors of the room, but the script eventually breaks, please help me fix it.

local part = script.Parent
local db = false

part.Touched:Connect(function(h)
	if not db then
		db = true
		if h.Parent:FindFirstChild("Humanoid") then    
			game.ReplicatedStorage.RoomPlayers.Value = game.ReplicatedStorage.RoomPlayers.Value + 1
			wait(0.5)
			db = false
		end
    end
end)

part.TouchEnded:Connect(function(h)
	if not db then
		db = true
    	if h.Parent:FindFirstChild("Humanoid") then
       		game.ReplicatedStorage.RoomPlayers.Value = game.ReplicatedStorage.RoomPlayers.Value - 1
			wait(0.5)
			db = false
		end
    end
end)

i did not put the other script bc its just a simple while loop that sets the gui value to the int value